Sum of two adjacent numbers are primes: Difference between revisions

Added Quackery.
m (syntax highlighting fixup automation)
(Added Quackery.)
Line 793:
36 + 37 = 73</pre>
 
=={{header|Quackery}}==
 
Every odd number is the sum of two adjacent numbers, so this task is "the first twenty odd primes" or "the first twenty primes after 2".
 
<code>isprime</code> is defined at [[Primality by trial division#Quackery]].
 
<syntaxhighlight lang="Quackery"> [ 1 [] rot
[ over size
over != while
dip
[ over isprime if
[ over join ]
dip [ 2 + ] ]
again ]
drop nip ] is oddprimes ( n --> [ )
 
[ oddprimes
witheach
[ dup 2 /
dup echo
say " + "
1+ echo
say " = "
echo cr ] ] is task ( n --> )
 
20 task</syntaxhighlight>
 
{{out}}
 
<pre>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>
 
=={{header|Raku}}==
1,462

edits