pub fn solve_pell(d: Integer) -> SolutionExpand description
Calculate fundamental solution of x^2 - d*y^2 = ±1
If d is negative or perfect square returns NotExist.
If x^2 - d*y^2 = -1 has nontrivial solution, returns its fundamental solution.
Otherwise returns fundamental solution of x^2 - d*y^2 = 1.
use rug::Integer;
let v = pell_equation::solve_pell(Integer::from(2));
assert_eq!(v, pell_equation::Solution::Negative(Integer::from(1), Integer::from(1)));
let w = pell_equation::solve_pell(Integer::from(3));
assert_eq!(w, pell_equation::Solution::Positive(Integer::from(2), Integer::from(1)));