Sum of two adjacent numbers are primes: Difference between revisions

→‎{{header|Wren}}: Recoded to do extra credit.
(→‎{{header|Go}}: Recoded to do extra credit.)
(→‎{{header|Wren}}: Recoded to do extra credit.)
Line 765:
 
=={{header|Wren}}==
{{trans|Go}}
{{libheader|Wren-math}}
{{libheader|Wren-fmt}}
Line 770 ⟶ 771:
import "./fmt" for Fmt
 
var limit = (1e7.log * 1e7 * 1.2).floor // should be more than enough
var primes = Int.primeSieve(limit)
System.print("The first 20 pairs of natural numbers whose sum is prime are:")
for (i in 1..20) {
var count = 0
var np = 1primes[i]
var hp = (p/2).floor
while (count < 20) {
if (IntFmt.isPrimeprint(2*n"$2d + $2d = $2d", hp, hp + 1)), {p)
}
Fmt.print("$2d + $2d = $2d", n, n + 1, 2*n + 1)
System.print("\nThe 10 millionth such pair is:")
count = count + 1
var p = primes[1e7]
}
var hp = (p/2).floor
n = n + 1
Fmt.print("$2d + $2d = $2d", nhp, nhp + 1, 2*n + 1p)</lang>
}</lang>
 
{{out}}
Line 804 ⟶ 807:
35 + 36 = 71
36 + 37 = 73
 
The 10 millionth such pair is:
89712345 + 89712346 = 179424691
</pre>
 
9,482

edits