|
import string
# questo programma genera tutte le combinazioni possibili
# fra i numeri primi che vanno da 3 a 4999 presenti nel file '5000.txt'
# e le scrive nel file 'data.txt'
def somma(i):
x = 0
while x < (len(n)-i):
l = str(n[i])+','+str(n[i+x])+','+str(n[i]+n[i+x])+'\n'
d.write(l)
x += 1
f = open('5000.txt','r').read()
num = string.split(f,',')
n = []
for element in num: # converto in interi i numeri considerati stringhe
n.append(int(element))
d = open('data.txt','w')
i = 0
while i < len(n):
somma(i)
i += 1
|
|