Twin primes: Difference between revisions

Added Arturo implementation
m (→‎optimized prime number generator: added more wording to the REXX section header.)
(Added Arturo implementation)
Line 94:
twin prime pairs below 10000000: 58980
</pre>
=={{header|Arturo}}==
 
<lang rebol>pairsOfPrimes: function [upperLim][
count: 0
j: 0
k: 1
i: 0
while [i=<upperLim][
i: (6 * k) - 1
j: i + 2
if and? [prime? i] [prime? j] [
count: count + 1
]
k: k + 1
]
return count + 1
]
 
ToNum: 10
while [ToNum =< 1000000][
x: pairsOfPrimes ToNum
print ["From 2 to" ToNum ": there are" x "pairs of twin primes"]
ToNum: ToNum * 10
]</lang>
 
{{out}}
 
<pre>From 2 to 10 : there are 3 pairs of twin primes
From 2 to 100 : there are 9 pairs of twin primes
From 2 to 1000 : there are 35 pairs of twin primes
From 2 to 10000 : there are 205 pairs of twin primes
From 2 to 100000 : there are 1224 pairs of twin primes
From 2 to 1000000 : there are 8169 pairs of twin primes</pre>
 
=={{header|AWK}}==
<lang AWK>
1,532

edits