Sum of two adjacent numbers are primes: Difference between revisions
Sum of two adjacent numbers are primes (view source)
Revision as of 11:02, 6 February 2022
, 2 years ago→{{header|Go}}: Recoded to do extra credit.
(Added Go) |
(→{{header|Go}}: Recoded to do extra credit.) |
||
Line 456:
import (
"fmt"
"math"
"rcu"
)
func main() {
limit := int(math.Log(1e7) * 1e7 * 1.2) // should be more than enough
primes := rcu.Primes(limit)
fmt.Println("The first 20 pairs of natural numbers whose sum is prime are:")
}▼
}
fmt.Println("\nThe 10 millionth such pair is:")
p := primes[1e7]
fmt.Printf("%2d + %2d = %2d\n", hp, hp+1, p)
}</lang>
Line 493 ⟶ 498:
35 + 36 = 71
36 + 37 = 73
The 10 millionth such pair is:
89712345 + 89712346 = 179424691
</pre>
|