Sum of primes in odd positions is prime: Difference between revisions

(Added 11l)
Line 794:
653 17959
823 26879
</pre>
 
=={{header|Yabasic}}==
{{trans|XPL0}}
<lang Yabasic>// Rosetta Code problem: http://rosettacode.org/wiki/Sum_of_primes_in_odd_positions_is_prime
// by Galileo, 04/2022
 
sub isPrime(n)
local i
if n < 4 return n >= 2
for i = 2 to sqrt(n)
if not mod(n, i) return false
next
return true
end sub
 
print "p(n)\tsum\n----\t------"
for n = 2 to 999
if isPrime(n) then
i = i + 1
if mod(i, 2) then
sum = sum + n
if isPrime(sum) print n, "\t", sum
end if
end if
next</lang>
{{out}}
<pre>p(n) sum
---- ------
2 2
5 7
31 89
103 659
149 1181
331 5021
467 9923
499 10909
523 11941
653 17959
823 26879
---Program done, press RETURN---
</pre>
672

edits