Beispiel #1
0
def solve():
    factors = [0] * 20
    accum = 1
    sieve(20)
    for i in xrange(1, 21):
        for p,k in factor(i):
            if k > factors[p-1]:
                accum *= p ** (k - factors[p-1])
                factors[p-1] = k
    return accum
Beispiel #2
0
def I(n):
    terms = []
    for (p,k) in factor(n):
        if p % 2 == 0 and k>1:
            residues = (1, -1, (1<<k-1)-1, (1<<k-1)+1)
        else:
            residues = (1, -1)
        pk = p**k
        coef = n // pk * modInverse(n // pk, pk)
        terms.append(map(lambda x: x*coef, residues))
    return max(filter(lambda x: x != n-1, (sum(res) % n for res in cross(*terms))))
Beispiel #3
0
def factor(n, primes=None):
    return set(lib.factor(n, primes=primes).items())
Beispiel #4
0
from eulerlib import factor
factors = factor(600851475143)
print factors[len(factors) - 1]
Beispiel #5
0
def divisors(n):
    if n == 1: return 1
    F = factor(n)
    return reduce(lambda x, y: x * y, [F.count(i) + 1 for i in set(F)])
Beispiel #6
0
from eulerlib import factor

n = 1
while True:
	satisfied = True
	for i in xrange(n,n+4):
		if len(set(factor(i))) != 4:
			satisfied = False
			break
	if satisfied:
		print range(n,n+4)
		break
	n += 1
Beispiel #7
0
from eulerlib import factor
factors = factor(600851475143)
print factors[len(factors)-1]
Beispiel #8
0
def divisors(n):
	if n == 1: return 1
	F = factor(n)
	return reduce( lambda x,y: x*y , [F.count(i)+1 for i in set(F)] )