Prime numbers p for which the sum of primes less than or equal to p is prime: Difference between revisions
Prime numbers p for which the sum of primes less than or equal to p is prime (view source)
Revision as of 19:17, 24 May 2024
, 23 days agoAdded Easylang
(Added Uiua solution) |
(Added Easylang) |
||
Line 178:
</pre>
=={{header|EasyLang}}==
<syntaxhighlight>
fastfunc isprim num .
i = 2
while i <= sqrt num
if num mod i = 0
return 0
.
i += 1
.
return 1
.
fastfunc nextprim prim .
repeat
prim += 1
until isprim prim = 1
.
return prim
.
prim = 2
repeat
sum += prim
if isprim sum = 1
write prim & " "
.
prim = nextprim prim
until prim >= 1000
.
</syntaxhighlight>
{{out}}
<pre>
2 3 7 13 37 43 281 311 503 541 557 593 619 673 683 733 743 839 881 929 953
</pre>
=={{header|F_Sharp|F#}}==
Line 185 ⟶ 219:
primes32()|>Seq.takeWhile((>)1000)|>Seq.scan(fun(n,_) g->(n+g,g))(0,0)|>Seq.filter(fun(n,_)->isPrime n)|>Seq.iter(fun(_,n)->printf "%d " n); printfn ""
</syntaxhighlight>
=={{header|Factor}}==
{{works with|Factor|0.99 2021-06-02}}
|