Function solve_pell

Source
pub fn solve_pell(d: Integer) -> Solution
Expand description

Calculate fundamental solution of x^2 - d*y^2 = ±1

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)));