10001th prime: Difference between revisions
Content added Content deleted
(→{{header|Picat}}: Forgot the essential predicates.) |
|||
Line 454: | Line 454: | ||
% faster but probably considered cheating |
% faster but probably considered cheating |
||
nth(10001,primes(200000),P), |
nth(10001,primes(200000),P), |
||
println(P). |
println(P). |
||
nth_prime(Choosen) = P => |
|||
nth_prime(1,0,Choosen, P). |
|||
nth_prime(Num, Choosen, Choosen, Num) :- |
|||
prime(Num). |
|||
nth_prime(Num, Ix, Choosen, P) :- |
|||
Ix < Choosen, |
|||
next_prime(Num, P2), |
|||
nth_prime(P2, Ix+1, Choosen, P). |
|||
next_prime(Num, P) :- |
|||
next_prime2(Num+1, P). |
|||
next_prime2(Num, Num) :- |
|||
prime(Num). |
|||
next_prime2(Num, P) :- |
|||
next_prime2(Num+1,P).</lang> |
|||
{{out}} |
{{out}} |