pyjacket.ntheory.modulo package

Submodules

pyjacket.ntheory.modulo.modular_arithmetic module

pyjacket.ntheory.modulo.modular_arithmetic.digits(n: int, base: int = 10) list[int][source]

Obtain the digits of an integer in any number base

Parameters:
  • n (int) – number of which to obtain the digits

  • base (int, optional) – base of number system, by default 10

Returns:

digits of n

Return type:

list

Raises:

ValueError – Number base must be larger than 1 Number should be an integer

Examples

>>> digits(137)
[1, 3, 7]
>>> digits(254, 16)
[15, 14]  # 255 = 15*16 + 14
pyjacket.ntheory.modulo.modular_arithmetic.gcd_extended(a, b)[source]

Implement the extended euclidian algorithm a*x + b*y = gcd(a, b)

pyjacket.ntheory.modulo.modular_arithmetic.modular_inverse(num, modulo)[source]
pyjacket.ntheory.modulo.modular_arithmetic.modular_pow(a, b, *, mod)[source]

Modular exponentiation a^b 5 ** 117 = 5 ** (1 + 4 + 16 + 32 + 64)

pyjacket.ntheory.modulo.modular_arithmetic.modular_prod(*args, mod)[source]

Compute (a*b)%modulo

pyjacket.ntheory.modulo.modular_arithmetic.modular_sum(*args, mod)[source]

Compute (a+b)%modulo

Module contents

pyjacket.ntheory.modulo.gcd_extended(a, b)[source]

Implement the extended euclidian algorithm a*x + b*y = gcd(a, b)

pyjacket.ntheory.modulo.modular_inverse(num, modulo)[source]
pyjacket.ntheory.modulo.modular_pow(a, b, *, mod)[source]

Modular exponentiation a^b 5 ** 117 = 5 ** (1 + 4 + 16 + 32 + 64)

pyjacket.ntheory.modulo.modular_prod(*args, mod)[source]

Compute (a*b)%modulo

pyjacket.ntheory.modulo.modular_sum(*args, mod)[source]

Compute (a+b)%modulo