Example #1
0
def solve(max):
    tStart = time.time()
    primes = help.primesUpTo(math.ceil(math.sqrt(max)))
    
    mintotient = 1
    minratio = 1000
    
    for i in range(2, max):
        totient = help.totient(i, primes)
        if isPerm(i, totient) and minratio > i/totient:
            mintotient = totient
            minratio = i/totient
            print(i, mintotient, minratio)
    print("Run Time = " + str(time.time() - tStart))
Example #2
0
def getTot(p):
    if p not in solved:
        solved[p] = 1 + getTot(help.totient(p, pr))
    return solved[p]
Example #3
0
def resilience(d, primes):
    return help.totient(d, primes)/(d-1)
Example #4
0
def solve(max):
    tStart = time.time()
    pr = help.primesUpTo(math.ceil(math.sqrt(max)))
    print(sum(list(map(lambda n: help.totient(n, pr), range(2,max+1)))))
    print("Run Time = " + str(time.time() - tStart))