solve_pell_negative

Function solve_pell_negative 

Source
pub fn solve_pell_negative(d: &Integer, limit: Option<u64>) -> 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 NotExist.

use rug::Integer;
use pell_equation::Solution;
let v = pell_equation::solve_pell_negative(&Integer::from(2), None);
assert_eq!(v, Solution::Negative(Integer::from(1), Integer::from(1)));
let w = pell_equation::solve_pell_negative(&Integer::from(3), None);
assert_eq!(w, Solution::NotExist);
let v = pell_equation::solve_pell_negative(&Integer::from(109), Some(23));
assert_eq!(v, Solution::ReachedLimit);
let w = pell_equation::solve_pell_negative(&Integer::from(109), Some(24));
assert_eq!(w, Solution::Negative(Integer::from(8890182), Integer::from(851525)));