View Single Post
Old 2016-03-16, 06:18   #10
"Dana Jacobsen"
Feb 2011
Bangkok, TH

2×3×151 Posts

Nice, LaurV.

For multiperm I just did:
use ntheory ":all"; 'formultiperm { $n=join "",@_; say $n if is_prime($n); } [split //,"9293392505711486960894715862"];
For the shuffling I played with vecextract but then realized I didn't need it.
use ntheory ":all"; use List::Util "shuffle"; my $n; my @s=split //,"9293392505711486960894715862"; for (1..20) { do { $n = join "",shuffle(@s); } while !is_prime($n); say $n; }
Both leave the leading zeros. I could use fromdigits instead of a simple join, which removes the leading zeros, but it currently has a dumb bigint implementation so is noticeably slower. I could also just regex them away, but who cares.

Last fiddled with by danaj on 2016-03-16 at 06:25
danaj is offline   Reply With Quote