Example #1
0
def factors(x,i=0):
    if isprime2(x):return [x]
    p = sieve(int(x**.5))
    for j,prime in enumerate(p[i:]):
        tmp = x%prime
        if tmp==0:
            tp = x//prime
            print(tmp,prime)
            return [prime]+factors(tp,j)
    return [x]
Example #2
0
def factors(x, i=0):
    if isprime2(x): return [x]
    p = sieve(int(x**.5))
    for j, prime in enumerate(p[i:]):
        tmp = x % prime
        if tmp == 0:
            tp = x // prime
            print(tmp, prime)
            return [prime] + factors(tp, j)
    return [x]
Example #3
0
def e133():
    L, q, s = 100000, pow(10, 20), 5
    for p in sieve(L)[1:]:
        if pow(10, q, p) != 1: s += p
    return s
Example #4
0
def e003(num=600851475143):
    p = sieve(round(num**.5))
    for i in p[::-1]:
        if num % i: continue
        else: return i
Example #5
0
def e003(num=600851475143):
    p = sieve(round(num**.5))
    for i in p[::-1]:
        if num%i:continue
        else:return i
Example #6
0
def e005(top=20):
    return reduce(mul,[i**(ceil(log(top)/log(i))-1) for i in sieve(top)])