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

added Easylang
No edit summary
(added Easylang)
 
(5 intermediate revisions by 4 users not shown)
Line 266:
{{works with|Delphi|6.0}}
{{libheader|SysUtils,StdCtrls}}
 
Straight forward implementation of the problem
Uses the [[Extensible_prime_generator#Delphi|Delphi Prime-Generator Object]]
 
<syntaxhighlight lang="Delphi">
Line 315 ⟶ 316:
</pre>
 
=={{header|EasyLang}}==
{{trans|11l}}
<syntaxhighlight>
fastfunc isprim num .
i = 2
while i <= sqrt num
if num mod i = 0
return 0
.
i += 1
.
return 1
.
for p = 2 to 999
if isprim p = 1
idx += 1
if idx mod 2 <> 0
s += p
if isprim s = 1
write "(" & idx & " " & p & " " & s & ") "
.
.
.
.
</syntaxhighlight>
{{out}}
<pre>
(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|F_Sharp|F#}}==
Line 336 ⟶ 366:
i=143 p[i]=823 sum=26879
</pre>
 
=={{header|Factor}}==
{{works with|Factor|0.99 2021-06-02}}
Line 672 ⟶ 703:
119 653 17,959
143 823 26,879
</pre>
 
=={{header|Quackery}}==
 
<code>isprime</code> is defined at [[Primality by trial division#Quackery]].
 
<syntaxhighlight lang="Quackery"> [ dip number$
over size -
space swap of
swap join echo$ ] is justify ( n n --> )
 
[] 1000 times
[ i^ isprime if [ i^ join ] ]
[] swap witheach
[ i^ 1 & 0 = iff join else drop ]
0 swap witheach
[ tuck + dup isprime if
[ i^ 2 * 1+ 3 justify
over 5 justify
dup 7 justify
cr ]
nip ]
drop</syntaxhighlight>
 
{{out}}
 
<pre> 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>
 
Line 786 ⟶ 854:
143 823 26879
done...
</pre>
 
=={{header|RPL}}==
{{works with|HP|49}}
≪ → max
≪ { } 0 2
1 max '''FOR''' j
SWAP OVER + SWAP
'''IF''' OVER ISPRIME? '''THEN'''
j OVER 4 PICK →V3
4 ROLL SWAP + UNROT
'''END'''
NEXTPRIME NEXTPRIME
'''IF''' DUP max ≥ '''THEN''' max 'j' STO '''END'''
2 '''STEP'''
DROP2
≫ ≫ '<span style="color:blue">TASK</span>' STO
 
1000 <span style="color:blue">TASK</span>
{{out}}
<pre>
1:. {[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>
 
Line 881 ⟶ 971:
{{libheader|Wren-iterate}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./math" for Int
import "./iterate" for Indexed
import "./fmt" for Fmt
 
var primes = Int.primeSieve(999)
2,083

edits