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)
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
def largest_prime_factor(n): prime = Prime() return max(prime.factor(n).keys())