Sum of primes in odd positions is prime: Difference between revisions
Sum of primes in odd positions is prime (view source)
Revision as of 15:06, 9 March 2023
, 1 year agoadded Arturo
m (→{{header|Wren}}: Wren-trait -> Wren-iterate) |
Drkameleon (talk | contribs) (added Arturo) |
||
Line 146:
143 823 26879
</pre>
=={{header|Arturo}}==
<syntaxhighlight lang="arturo">print " i | p(i) sum"
print repeat "-" 17
idx: 0
sm: 0
p: 1
while [p < 1000][
inc 'p
if prime? p [
inc 'idx
if odd? idx [
sm: sm + p
if prime? sm ->
print (pad to :string idx 4) ++ " | " ++ (pad to :string p 3) ++ (pad to :string sm 6)
]
]
]</syntaxhighlight>
{{out}}
<pre> i | p(i) sum
-----------------
1 | 2 2
3 | 5 7
11 | 31 89
27 | 103 659
35 | 149 1181
67 | 331 5021
91 | 467 9923
95 | 499 10909
99 | 523 11941
119 | 653 17959
143 | 823 26879</pre>
=={{header|AWK}}==
|