The below code is to output an array containing all the primes up to a limit. My code above does not do so, I cannot determine where the error is.
#generate prime numbers up to a given value
pa=[2]
limit=13
k=2
while k<limit:
for i in pa:
if k%i==0:
k+=1
else:
pa.append(k)
k+=1
print pa
Aucun commentaire:
Enregistrer un commentaire