def A(n): if n % 2 == 0 or n % 5 == 0: return 0 for k in divisorList(totient(9*n)): if pow(10, k, 9*n) == 1: return k
from numbertheory import primeList import numbertheory def residues(n, m): for i in range(m): yield pow(i, n, m) n = 13 for m in primeList(1000): t = numbertheory.totient(m) r = list(residues(n, m)) r = list(set(r)) r.sort() if m % n == 1 and numbertheory.isPrime(m): print(m , len(r), r)
def teration(a, n, m): if n == 0 or m == 1: return 1 return pow(a, teration(a, n-1, totient(m)),m)
from numbertheory import totient s = 0 for x in range(2, 1000000 + 1): s += totient(x) print(s)