Quadrat special primes: Difference between revisions

Initial FutureBasic task solution added
(Realize in F#)
(Initial FutureBasic task solution added)
Line 408:
2 3 7 11 47 83 227 263 587 911 947 983 1019 1163 1307 1451 1487 1523 1559 2459 3359 4259 4583 5483 5519 5843 5879 6203 6779 7103 7247 7283 7607 7643 8219 8363 10667 11243 11279 11423 12323 12647 12791 13367 13691 14591 14627 14771 15671
</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 QuadratSpecialPrimes
NSUInteger p = 2, j = 1, count = 1
printf @"%6lu \b", 2
while (1)
count++
while (1)
if fn IsPrime( p + j*j ) then exit while
j += 1
wend
p += j*j
if p > 16000 then exit while
printf @"%6lu \b", p
if count == 10 then count = 0 : print
j = 1
wend
print
end fn
 
fn QuadratSpecialPrimes
 
HandleEvents
</syntaxhighlight>
{{output}}
<pre>
2 3 7 11 47 83 227 263 587 911
947 983 1019 1163 1307 1451 1487 1523 1559 2459
3359 4259 4583 5483 5519 5843 5879 6203 6779 7103
7247 7283 7607 7643 8219 8363 10667 11243 11279 11423
12323 12647 12791 13367 13691 14591 14627 14771 15671
</pre>
 
=={{header|Go}}==
715

edits