示例#1
0
'''
Created on Jan 11, 2011

@author: Jeff Patti
'''

import useful_functions

primes = useful_functions.prime_sequence()


sum = 0
while True:
    next = primes.next()
    if next > 2000000:
        break
    sum+=next
print sum
示例#2
0
'''
Created on Feb 6, 2011

@author: Jeff Patti
'''

import useful_functions
from collections import defaultdict



prime_gen = useful_functions.prime_sequence()

prime_set = set()
prime_list = []
while True:
    val = prime_gen.next()
    if val > 30000:
        break
    prime_set.add(val)
    prime_list.append(val)
    

prime_groups = defaultdict(list)


    
for prime in prime_list:
    if prime < 1000:
        continue
    if prime > 10000:
示例#3
0
'''
Created on Jan 16, 2012

@author: Jeff Patti
'''
import useful_functions

primes = []
prime_set = set()

prime_generator = useful_functions.prime_sequence()
for prime in prime_generator:
    if prime > 1000000:
        break
    primes.append(prime)
    prime_set.add(prime)

print primes
print len(primes)

num_primes = len(primes)

for j in range(20, 1000):
    for i in range(len(primes)):
        if num_primes < i + j:
            continue

        slice = primes[i:i + j]
        #print slice
        summed = sum(slice)
        if summed > 1000000:
示例#4
0
'''
Created on Jan 15, 2011

@author: Jeff Patti
'''

import useful_functions

primes = set()

prime_generator = useful_functions.prime_sequence()

for i in range(2000):
    primes.add(prime_generator.next())
     
def how_many_primes(a, b):
    n = 0
    evaluate = lambda n, a, b : n*n + a*n + b  
    while True:
        iteration = evaluate(n,a,b)
        if iteration not in primes:
            return n
        n += 1
            
print how_many_primes(1, 41)

max_a = 0
max_b = 0
max_primes = 0
for a in range(-1000,1001):
    for b in range(-1000,1001):