10001th prime: Difference between revisions
→{{header|Prolog}}
Line 501:
104743</pre>
=={{header|Prolog}}==
<
isPrime(N):-
between(3, inf, N), % prime generator
N /\ 1 > 0, % odd
M is floor(sqrt(N)) - 1, % reverse 2*I+1
Max is M div 2,
forall(between(1, Max, I), N mod (2*I+1) > 0).
do:- Index is 10001,
findnsols(Index, N, isPrime(N), PrimeList),!,
last(PrimeList, PrimeAtIndex),
format('prime(~w) is ~w', [Index, PrimeAtIndex]), nl.</syntaxhighlight>
{{out}}
<pre>
prime(10001) is 104743
true.</pre>
=={{header|Python}}==
|