On Mon, 2010-04-05 at 19:13 +0200, Luigi Marino wrote:
> This block finds the nth-primenumber I hope that it is usefull for
> anyone. primo(n):=block(
> if n=1 then return(2) else(p:1,
> k:1),
> while k#n do
> (p:p+2,
> d:2,
> while (d*d<=p and mod(p ,d)#0) do
> (d:d+1),
> if d*d>p then k:k+1),
> return(p))$
Another way to do it:
primo2(n) := block([i : n, p : 2],
while i > 1 do (i : i - 1, p : next_prime(p)),
return(p))$
primo2(15);
47
Regards,
Jaime