This commit is contained in:
Emile Clark-Boman 2025-06-11 11:11:35 +10:00
commit c743ca0b85
3 changed files with 103 additions and 0 deletions

24
prbraid/math.py Normal file
View file

@ -0,0 +1,24 @@
# Euler's Totient (Phi) Function
def totient(n):
phi = int(n > 1 and n)
for p in range(2, int(n ** .5) + 1):
if not n % p:
phi -= phi // p
while not n % p:
n //= p
#if n is > 1 it means it is prime
if n > 1: phi -= phi // n
return phi
def orbit(b, m):
generated = []
x = b
for i in range(m):
x = (x * b) % m
if x not in generated:
generated.append(x)
return generated
def order(b, m):
return len(orbit(b, m))