def problem132(): found = [] for p in iPrime(): if pow(10,10**9,9*p) == 1: found.append(p) if len(found) == 40: break return sum(found)
def problem381(): total = 0 for p in iPrime(5): if p >= 10**8: break total += S(p) return total
def problem133(): total = 2 + 3 + 5 for p in dropwhile(lambda x: x < 6, iPrime()): if p > 10**5: break #print(p, order(10,p)) if not multipleOf2and5(order(10,p)): total += p print(p) return total
def problem293(): GOAL = 10**3 primes = [] maximum = 1 for p in iPrime(): maximum *= p primes.append(p) if maximum > GOAL: break print(primes) admissible = [] for c in generateAdmissible(GOAL,primes): admissible.append(c) print(sorted(admissible))
def problem111(GOAL): M = [0]*10 N = [[],[],[],[],[],[],[],[],[],[]] for p in dropwhile(lambda x: x<10**GOAL, iPrime()): if p > 10**(GOAL + 1): break sp = str(p) for i in range(0,10): if sp.count(str(i)) > M[i]: M[i] = sp.count(str(i)) N[i] = [] if sp.count(str(i)) == M[i]: N[i].append(p) for i in range(len(N)): print(i, M[i], sum(N[i]))
def problem216(): count = 0 for p in iPrime(): print(jacobi(( p + 1)//2, p)) if p > 100: break return for index, n in enumerate(t(100)): index += 2 #print( 2*(index)**2 -1 , n, isPrime(n), jacobi(( index + 1)//2, index)) if isPrime(n): count += 1 print("gave a prime ", jacobi(( n + 1)//2, n)) else: for p in factorize(n): print("Didn't give a prime", p,jacobi(( p + 1)//2, p)) return count
def problem293(): GOAL = 10**9 primes = [] maximum = 1 for p in iPrime(): maximum *= p primes.append(p) # need one more beyond what is required if maximum > GOAL: break admissible = [] total = 0 num = 0 for c in generateAdmissible(GOAL,primes): #print(c, sorted(factorize(c))) if c > GOAL: continue num += 1 for d in count(3,2): if isPrime(c+d): total += d break return num, total