10001th prime: Difference between revisions

Initial FutureBasic task solution added
No edit summary
(Initial FutureBasic task solution added)
Line 565:
<syntaxhighlight lang="frink">nth[primes[], 10001-1]</syntaxhighlight>
{{out}}
<pre>
104743
</pre>
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
 
local fn IsPrime( n as NSUInteger ) as BOOL
BOOL isPrime = YES
NSUInteger i
if n < 2 then exit fn = NO
if n = 2 then exit fn = YES
if n mod 2 == 0 then exit fn = NO
for i = 3 to int(n^.5) step 2
if n mod i == 0 then exit fn = NO
next
end fn = isPrime
 
 
local fn Prime( n as NSUInteger ) as long
long p = 3, pn = 1
if n = 1 then exit fn = 2
while ( pn < n )
if fn IsPrime( p ) then pn++
p += 2
wend
p -= 2
end fn = p
 
print fn Prime(10001)
 
HandleEvents
</syntaxhighlight>
{{output}}
<pre>
104743
723

edits