Sum of two adjacent numbers are primes: Difference between revisions
Sum of two adjacent numbers are primes (view source)
Revision as of 21:58, 17 February 2024
, 3 months agoAdded Easylang
(Created Nim solution.) |
(Added Easylang) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 622:
</pre>
=={{header|EasyLang}}==
{{trans|BASIC256}}
<syntaxhighlight>
fastfunc isprim num .
i = 2
while i <= sqrt num
if num mod i = 0
return 0
.
i += 1
.
return 1
.
print "The first 20 pairs of numbers whose sum is prime:"
repeat
n += 1
sum = 2 * n + 1
if isprim sum = 1
print n & " + " & n + 1 & " = " & sum
cnt += 1
.
until cnt = 20
.
</syntaxhighlight>
=={{header|F_Sharp|F#}}==
Line 1,473 ⟶ 1,498:
36 + 37 = 73
done...
</pre>
=={{header|RPL}}==
{{works with|HP|49}}
≪ { } 2
'''WHILE''' OVER SIZE 20 < '''REPEAT'''
NEXTPRIME
DUP 2 IQUOT →STR
LASTARG SWAP "+" + SWAP 1 + + "=" + OVER +
ROT SWAP + SWAP
'''END''' DROP
≫ 'TASK' STO
{{out}}
<pre>
1: {"1+2=3" "2+3=5" "3+4=7" "5+6=11" "6+7=13" "8+9=17" "9+10=19" "11+12=23" "14+15=29" "15+16=31" "18+19=37" "20+21=41" "21+22=43" "23+24=47" "26+27=53" "29+30=59" "30+31=61" "33+34=67" "35+36=71" "36+37=73"}
</pre>
Line 1,542 ⟶ 1,582:
{{libheader|Wren-math}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="
import "./fmt" for Fmt
|