1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| # Ce programme calcule les Nombres Premiers #
# Révolution : Vicenté Llavata au 25 avril 2014 #
# Initialisation de listeNPH.txt #
fo = open("C:\python\pynph\listeNPH.txt","r")
ft = fo.readline()
fo.close()
if (ft == ""):
fo = open("C:\python\pynph\listeNPH.txt","a")
fo.write("1\n","1\n")
fo.close()
# Fonction de recherche #
def calnph(a):
if (a > 1):
lfor = open("C:\python\pynph\listeNPH.txt","r")
lb = a #
lbb = (lb + 1) # Initie segment for(lbb)
lc = lb * 2 #
nreelexist = 0
#
for lbb in lc : # Segment for(lbb)
lba = lbb / lb # Réel lb
lbb = lbb + 1
while l :
nentier = float(lfor.readline())
nreel = float(lfor.readline())
if (lba == nreel) :
nreelexist = 1
break
if (nreelexist == 1) :
lbb == (lc + 1) # Terme for (lbb)
#
lfor.close()
if (nreelexist == 0) :
nentier1 = lb
nreel2 = lba
e = str(nentier1)
f = str(nreel2)
prenph(e,f)
# Fonction du premier réel #
def prenph(e,f):
lfoa = open("C:\python\pynph\listeNPH.txt","a")
lfoa.write(e,"\n")
lfoa.write(f,"\n")
lfoa.close()
# Introduction nombre utilisateur #
nombre = input("Entrez un nombre entier : ")
ne = int(nombre)
a = 0
# Début de la boucle globale (a) #
while (a <= ne) :
a = a + 1
nem = a%6
if (nem == (1 or 5)):
calnph(a) |
Partager