Skip to content

Commit

Permalink
example/almost_prime.pn added
Browse files Browse the repository at this point in the history
see http://rosettacode.org/wiki/Almost_prime
converted from the C version
  • Loading branch information
Reini Urban committed Sep 19, 2014
1 parent 9f13811 commit 1e2a57d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions example/almost_prime.pn
@@ -0,0 +1,23 @@
kprime = (n, k):
p = 2, f = 0
while (f < k && p*p <= n):
while (0 == n % p):
n /= p
f++.
p++.
n = if (n > 1): 1
. else: 0.
f + n == k.

k = 1
while (k <= 5):
"k = " print, k print, ":" print
i = 2, c = 0
while (c < 10):
if (kprime(i, k)):
" " print, i print
c++.
i++
.
k++
"" say.

0 comments on commit 1e2a57d

Please sign in to comment.