Jump to content

Repunit primes: Difference between revisions

→‎{{header|Wren}}: Using a more efficient method to calculate repunit strings, a bit quicker overall.
(→‎{{header|Wren}}: Using a more efficient method to calculate repunit strings, a bit quicker overall.)
Line 284:
An embedded program so we can use GMP as I know from experience that Wren-CLI (using BigInt) will not be able to complete this task in a reasonable time.
 
Still takes a while - 11 minutes 4220 seconds to get up to base 36 with a limit of 2700.
<lang ecmascript>/* repunit_primes.wren */
 
Line 290:
import "./math" for Int
import "./fmt" for Fmt
import "./str" for Str
 
var limit = 2700
Line 297 ⟶ 298:
var rPrimes = []
for (p in primes) {
var s = Mpz.fromStr(Str.repeat("1" *, p), b)
if (s.probPrime(15) > 0) rPrimes.add(p)
}
9,483

edits

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