Sum of primes in odd positions is prime: Difference between revisions
Content added Content deleted
(J) |
m (→{{header|J}}: adjust expression so it would remain correct even if 1000 were replaced with a prime number) |
||
Line 359: | Line 359: | ||
=={{header|J}}== |
=={{header|J}}== |
||
<syntaxhighlight lang=J> (i,.p,.sum) #~ 1 p: sum=. +/\ |
<syntaxhighlight lang=J> (i,.p,.sum) #~ 1 p: sum=. +/\p=. p:<:i=. (#~ 2|])i. 2+p:inv 1000 |
||
1 2 2 |
1 2 2 |
||
3 5 7 |
3 5 7 |