Permalink
6dd6325 Jul 26, 2015
@robertwb @williamstein @scoder
23 lines (20 sloc) 402 Bytes
# cython: language_level=3
print("starting")
def primes(int kmax):
# cdef int n, k, i
cdef int p[1000]
result = []
if kmax > 1000:
kmax = 1000
k = 0
n = 2
while k < kmax:
i = 0
while i < k and n % p[i] != 0:
i += 1
if i == k:
p[k] = n
k += 1
result.append(n)
n += 1
return result