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.
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,

chinese_remainder

Integer.chinese_remainder(_cls, 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(_cls, a, b)

Compute the greatest common divisor of the numbers a and b and the Bézout coefficients.

gcd

Integer.gcd(_cls, a, b)

Compute the greatest common divisor of the numbers a and b.

is_prime

Integer.is_prime(_cls, n)

Check if the 64-bit number n is a prime number.

lcm

Integer.lcm(_cls, a, b)

Compute the least common multiple of the numbers a and b.

prime_iter

Integer.prime_iter(_cls, start=1)

Create an iterator over all 64-bit prime numbers starting from start.

solve_integer_relation

Integer.solve_integer_relation(_cls, x, tolerance, 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].