10001th prime: Difference between revisions

no edit summary
imported>Nmz
m (→‎Idiomatic awk: forgot a variable)
No edit summary
Line 658:
 
=={{header|Fermat}}==
<syntaxhighlight lang="fermatpascal">
Prime(10001);
</syntaxhighlight>
{{out}}<pre>104743</pre>
 
=={{header|FreePascal}}==
<syntaxhighlight lang="fermat">
Program nth_prime;
 
Function nthprime(x : uint32): uint32;
Var primes : array Of uint32;
i,pr,count : uint32;
found : boolean;
Begin
setlength(primes, x);
primes[1] := 2;
count := 1;
i := 3;
Repeat
found := FALSE;
pr := 0;
Repeat
inc(pr);
found := i Mod primes[pr] = 0;
Until (primes[pr]*primes[pr] > i) Or found;
If Not found Then
Begin
inc(count);
primes[count] := i;
End;
inc(i,2);
Until count = x;
nthprime := primes[x];
End;
 
Begin
writeln(nthprime(10001));
End.
 
</syntaxhighlight>
{{out}}<pre>104743</pre>
 
 
 
 
=={{header|Frink}}==
45

edits