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

Added XPL0 example.
(Added Go)
(Added XPL0 example.)
Line 146:
119 653 17,959
143 823 26,879
</pre>
 
=={{header|XPL0}}==
<lang XPL0>func IsPrime(N); \Return 'true' if N is a prime number
int N, I;
[if N <= 1 then return false;
for I:= 2 to sqrt(N) do
if rem(N/I) = 0 then return false;
return true;
];
 
int I, Sum, N;
[Text(0, "p(n) sum^m^j");
Sum:= 0; I:= 0;
for N:= 2 to 1000-1 do
[if IsPrime(N) then
[I:= I+1;
if I&1 then \odd
[Sum:= Sum + N;
if IsPrime(Sum) then
[IntOut(0, N); ChOut(0, ^ ); IntOut(0, Sum); CrLf(0)];
];
];
];
]</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
</pre>
772

edits