Sum of two adjacent numbers are primes: Difference between revisions
Sum of two adjacent numbers are primes (view source)
Revision as of 12:57, 6 February 2022
, 2 years ago→{{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
var hp = (p/2).floor
}
Fmt.print("$2d + $2d = $2d", n, n + 1, 2*n + 1)▼
System.print("\nThe 10 millionth such pair is:")
var p = primes[1e7]
var hp = (p/2).floor
{{out}}
Line 804 ⟶ 807:
35 + 36 = 71
36 + 37 = 73
The 10 millionth such pair is:
89712345 + 89712346 = 179424691
</pre>
|