예제 #1
0
def coprimes(L,report_progress=False):
    if report_progress:
        t = sum(totients(L))
        itr = 0.
    for d,n in ((2,1),(3,1)):
        for i,j in _coprimes(d,n,L,report_progress):
            if report_progress:
                print str(100*itr/t)[:5]+"%"," "*20,"\r",
                itr += 1
            yield i,j
    if report_progress:
        print
예제 #2
0
from totient import totients
import time

N = 10**7
L = N+1
t = totients(N)
print min((float(i)/t[i],i) for i in xrange(2,L) if sorted(str(i)) == sorted(str(t[i])))
예제 #3
0
def solve(): return sum(i for i in totients(10**6)[2:])

from timer import time_function
예제 #4
0
    quit = 0
    while len(q) > 0:
        quit += 1
        nxt = q.pop()
        if nxt[1] >= L or nxt[0] > L or nxt[1] > nxt[0]:
            continue
        else:
            yield nxt
            q.append((2*nxt[0]-nxt[1],nxt[0]))
            q.append((2*nxt[0]+nxt[1],nxt[0]))
            q.append((nxt[0]+2*nxt[1],nxt[1]))


c = 0
L = 12000
t = sum(i for i in totients(L))
d = 2
n = 1
a = 0
for i,j in coprimes(d,n,L):
    print str(100.*a/t)[:5]+"% of space searched\r",
    if .5 > float(j)/i > 1./3:
        c += 1
    a += 1
d = 3
n = 1
for i,j in coprimes(d,n,L):
    print str(100.*a/t)[:5]+"% of space searched\r",
    if .5 > float(j)/i > 1./3:
        c += 1
    a += 1
예제 #5
0
def solve():
    N = 10**7
    L = N+1
    t = totients(N)
    return min((float(i)/t[i],i) for i in range(2,L) if sorted(str(i)) == sorted(str(t[i])))
예제 #6
0
from totient import totients

rint sum(i for i in totients(10**6)[2:])