from zMath import PrimeGen maxNum = 1000000 primegen = PrimeGen(maxNum) longestChain = 0 resultingPrime = 0 for primeIndex in range(0, len(primegen.primes)): chain = 0 sum = 0 while sum<maxNum and primeIndex+chain<len(primegen.primes): if primegen.isPrimeHash(sum) and chain>longestChain: longestChain = chain resultingPrime = sum sum += primegen.primes[primeIndex+chain] chain += 1 #print longestChain print resultingPrime
from zMath import numericPermutations from zMath import PrimeGen import sets primegen = PrimeGen(10000) primes = list() for p in range(1001, 10001, 2): if primegen.isPrimeHash(p): primes.append(p) permutationGroups = dict() for num in primes: numSet = frozenset(str(num)) if numSet not in permutationGroups: permutationGroups[numSet] = list() permutationGroups[numSet].append(num) for numSet, numList in permutationGroups.items(): if len(numList) < 3: del permutationGroups[numSet] for numList in permutationGroups.itervalues(): #print numList for i in range(0, len(numList)-2): for j in range(i+1, len(numList)-1): num1 = numList[i] num2 = numList[j] num3 = num2 - (num1 - num2)
from zMath import PrimeGen from math import sqrt maxNum = 10000 primes = PrimeGen(maxNum) print "Primes generated" composite = 3 while True: if primes.isPrimeHash(composite): composite += 2 continue found = False for sq in range(1, int(sqrt(composite))): primeDifference = composite - 2*sq**2 if primes.isPrimeHash(primeDifference): #print str(composite) + " = "+str(sq)+"^2 + " + str(primeDifference) found = True break if not found or composite > maxNum: print composite break else: composite += 2