Integer
Integer()Methods
| Name | Description |
|---|---|
| chinese_remainder | Solve the Chinese remainder theorem for the equations: |
| extended_gcd | Compute the greatest common divisor of the numbers a and b and the Bézout coefficients. |
| factor | Factor a 64-bit number n into primes. |
| gcd | Compute the greatest common divisor of the numbers a and b. |
| is_prime | Check if the 64-bit number n is a prime number. |
| lcm | Compute the least common multiple of the numbers a and b. |
| prime_iter | Create an iterator over all 64-bit prime numbers starting from start. |
| solve_integer_relation | Use the PSLQ algorithm to find a vector of integers a that satisfies a.x = 0, |
| totient | Compute the Euler totient function for the number n. |
chinese_remainder
Integer.chinese_remainder(n1, m1, n2, m2)Solve the Chinese remainder theorem for the equations: x = n1 mod m1 and x = n2 mod m2.
extended_gcd
Integer.extended_gcd(n1, n2)Compute the greatest common divisor of the numbers a and b and the Bézout coefficients.
factor
Integer.factor(n)Factor a 64-bit number n into primes.
gcd
Integer.gcd(n1, n2)Compute the greatest common divisor of the numbers a and b.
is_prime
Integer.is_prime(n)Check if the 64-bit number n is a prime number.
lcm
Integer.lcm(n1, n2)Compute the least common multiple of the numbers a and b.
prime_iter
Integer.prime_iter(start=1)Create an iterator over all 64-bit prime numbers starting from start.
solve_integer_relation
Integer.solve_integer_relation(
x,
tolerance,
max_iter=1000,
max_coeff=None,
gamma=None,
)Use the PSLQ algorithm to find a vector of integers a that satisfies a.x = 0, where every element of a is less than max_coeff, using a specified tolerance and number of iterations. The parameter gamma must be more than or equal to 2/sqrt(3).
Examples
Solve a 32.0177=b*pi+c*e where b and c are integers:
>>> r = Integer.solve_integer_relation([-32.0177, 3.1416, 2.7183], 1e-5, 100)
>>> print(r)yields [1,5,6].
totient
Integer.totient(n)Compute the Euler totient function for the number n.