Primzahlen
Verfasst: Montag 14. Februar 2005, 13:07
Ich brauche ein programm was so schnell wie möglich Primzahlen bis zur einer bestimmten zahl rausgibt.
Könnt ihr mir helfen das Programm zu tunen.
Schonmal danke im voraus
crosan
Edit (Leonidas): Code in Python Tags gesetzt.
Code: Alles auswählen
from time import time
e=input ("Nennen Sie einen Endwert: ")
g=time()
print 2
for i in range (3,e+1,2):
for j in range (3, i/2+1,2):
if i%j == 0:
break
else:
print i
f=time()
print "Das Programm hat %.2f Sekunden gebraucht." % (f-g)
Schonmal danke im voraus
crosan
Edit (Leonidas): Code in Python Tags gesetzt.