Summation of primes: Difference between revisions
Initial FutureBasic task solution added
(Created Nim solution.) |
(Initial FutureBasic task solution added) |
||
Line 355:
!!s;</syntaxhighlight>
{{out}}<pre>142913828922</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 SumOfPrimes as long
long sum = 2, i, n = 1
for i = 3 to 2000000 step 2
if ( fn IsPrime(i) )
sum += i
n++
end if
next
end fn = sum
print fn SumOfPrimes
HandleEvents
</syntaxhighlight>
{{output}}
<pre>
142913828922
</pre>
=={{header|Go}}==
|