Sum of two adjacent numbers are primes: Difference between revisions
Sum of two adjacent numbers are primes (view source)
Revision as of 12:14, 25 January 2022
, 2 years agoJ
(J) |
|||
Line 135:
20: 36 + 37=73
</pre>
=={{header|J}}==
Here, we generate the first 20 odd primes, divide by 2, drop the fractional part and add 0 and 1 to that value. Then we format that pair of numbers with their sum and with decorations indicating the relevant arithmetic:
<lang J> (+/,&":'=',{.,&":'+',&":{:)"#. 0 1+/~<.@-: p:1+i.20
3=1+2
5=2+3
7=3+4
11=5+6
13=6+7
17=8+9
19=9+10
23=11+12
29=14+15
31=15+16
37=18+19
41=20+21
43=21+22
47=23+24
53=26+27
59=29+30
61=30+31
67=33+34
71=35+36
73=36+37</lang>
=={{header|Julia}}==
<lang julia>using Lazy
|