Menu

[r5337]: / trunk / py4science / examples / pyrex / primes / pyprimes.py  Maximize  Restore  History

Download this file

14 lines (13 with data), 240 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
def primes(kmax):
p = []
k = 0
n = 2
while k < kmax:
i = 0
while i < k and n % p[i] <> 0:
i = i + 1
if i == k:
p.append(n)
k = k + 1
n = n + 1
return p
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.