Skip to main content

carmichael_lambda

Function carmichael_lambda 

Source
pub fn carmichael_lambda(n: &BigInt) -> BigInt
Expand description

Computes Carmichael’s lambda function λ(n).

λ(n) is the exponent of the group (ℤ/nℤ)*. For any a coprime to n: a^λ(n) ≡ 1 (mod n).

§Examples

use num_bigint::BigInt;
use oxiz_math::rational::carmichael_lambda;

assert_eq!(carmichael_lambda(&BigInt::from(1)), BigInt::from(1));
assert_eq!(carmichael_lambda(&BigInt::from(8)), BigInt::from(2)); // λ(8) = 2
assert_eq!(carmichael_lambda(&BigInt::from(15)), BigInt::from(4)); // λ(15) = 4