from collections import Counter
from math import gcd
def factor(m):
n = m
f = []
for d in [2, 3, 5]:
while n % d == 0:
f.append(d)
n //= d
inc = (4, 2, 4, 2, 4, 6, 2, 6)
i, d = 0, 7
while d * d <= n:
while n % d == 0:
n //= d
f.append(d)
d += inc[i]
i = (i + 1) % 8
if n > 1:
f.append(n)
return Counter(f)
N = 10
lcm = lambda x, y: x * y // gcd(x, y)
cnt = factor(N - 1)
orders = []
for p, e in cnt.items():
print(p**(e-1))
divs = []
found = False
for c in range(1, int((p - 1)**0.5) + 1):
if (p - 1) % c == 0:
if pow(2, c, p) == 1:
print(p, "===>", c)
o = c
found = True
break
divs.append((p - 1) // c)
if not found:
print(divs)
for c in reversed(divs):
if pow(2, c, p) == 1:
print(p, "===>", c)
o = c
break
if pow(2, o, p**e) == 1:
orders.append(o)
elif pow(2, o * p**(e - 1), p**e) == 1:
orders.append(o * p**(e - 1))
print(orders)
res = 1
for o in orders:
res = lcm(res, o)
print(res)
To embed this program on your website, copy the following code and paste it into your website's HTML: