示例#1
0
文件: 216.py 项目: jguze/projecteuler
def main(n):
	limit = (2 * ((n + 1)**2)) - 1
	p = Prime()
	primes = p.sieve(limit)
	d = {
		x:True for x in primes
	}
	res = []
	for i in range(2, n + 1):
		t = (2 * (i**2)) - 1
		if t in d:
			res.append(t)
	return len(res)
示例#2
0
文件: 12.py 项目: jguze/projecteuler
def triangles():
	i = 3
	count = 3
	while True:
		prime = Prime()
		prime_factors = prime.factor(i)
		mul = 1;
		for key, amount in prime_factors.items():
			mul *= (amount + 1)
		if mul > 500:
		 	return i
		i += count
		count += 1
示例#3
0
文件: 3.py 项目: jguze/projecteuler
def largest_prime_factor(n):
	prime = Prime()
	return max(prime.factor(n).keys())