Jump to content

Penta-power prime seeds: Difference between revisions

Added Wren
(Change descriptions to match task rename)
(Added Wren)
Line 51:
nine million is the 71st: 9,100,671
ten million is the 72nd: 10,347,035</pre>
 
=={{header|Wren}}==
{{libheader|Wren-gmp}}
{{libheader|Wren-fmt}}
<lang ecmascript>import "./gmp" for Mpz
import "./fmt" for Fmt
 
var p = Mpz.new()
var q = Mpz.one
 
var isPentaPowerPrimeSeed = Fn.new { |n|
p.setUi(n)
var k = n + 1
return (q + k).probPrime(15) > 0 &&
(p + k).probPrime(15) > 0 &&
(p.mul(n) + k).probPrime(15) > 0 &&
(p.mul(n) + k).probPrime(15) > 0 &&
(p.mul(n) + k).probPrime(15) > 0
}
 
var ppps = []
var n = 1
while (ppps.count < 30) {
if (isPentaPowerPrimeSeed.call(n)) ppps.add(n)
n = n + 1
}
System.print("First thirty penta-power prime seeds:")
Fmt.tprint("$,9d", ppps, 10)
 
System.print("\nFirst penta-power prime seed greater than:")
n = 1
var m = 1
var c = 0
while (true) {
if (isPentaPowerPrimeSeed.call(n)) {
c = c + 1
if (n > m * 1e6) {
Fmt.print(" $2d million is the $r: $,10d", m, c, n)
m = m + 1
if (m == 11) return
}
}
n = n + 1
}</lang>
 
{{out}}
<pre>
First thirty penta-power prime seeds:
1 5 69 1,665 2,129 25,739 29,631 62,321 77,685 80,535
82,655 126,489 207,285 211,091 234,359 256,719 366,675 407,945 414,099 628,859
644,399 770,531 781,109 782,781 923,405 1,121,189 1,158,975 1,483,691 1,490,475 1,512,321
 
First penta-power prime seed greater than:
1 million is the 26th: 1,121,189
2 million is the 39th: 2,066,079
3 million is the 47th: 3,127,011
4 million is the 51st: 4,059,525
5 million is the 59th: 5,279,175
6 million is the 63rd: 6,320,601
7 million is the 68th: 7,291,361
8 million is the 69th: 8,334,915
9 million is the 71st: 9,100,671
10 million is the 72nd: 10,347,035
</pre>
9,486

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.