Beispiel #1
0
from FUF import primeList

pl = primeList(10000)

words = [str(each) for each in pl]

numdict = {}
for each in words:
    kwrd = list(str(each))
    kwrd.sort()
    kwrd = ''.join(kwrd)
    if kwrd in numdict:
	numdict[kwrd] = numdict[kwrd] + " " + each
    else:
	numdict[kwrd] = each
                                    
for each in numdict.keys():
    if numdict[each].count(" ")<2 or len(each) < 4:
        numdict.pop(each)
    else:
        a = [int(each) for each in numdict[each].split()]
        for i in range(len(a)):
            for j in range(i+1, len(a)):
                if a[j]*2 - a[i] in a:
                    print str(a[i]) + str(a[j]) + str(a[j]*2 - a[i])
Beispiel #2
0
from FUF import isPrime, primeList
from pylab import cumsum, find

pl = primeList(5000)
len = 0
max = 0
j = 0
for i in range(2500):
    spl = cumsum(pl[i:])
    spl = spl[spl < 1000000]
    splrev = spl[::-1]

    for item in splrev:
        if isPrime(item):
            pos = find(spl == item)
            if pos > len:
                len = pos
                max = item
                j = i
            break
    print max, len, j