View Single Post
Old 2016-03-16, 04:53   #8
LaurV
Romulan Interpreter
 
LaurV's Avatar
 
Jun 2011
Thailand

887010 Posts
Default

Found it! I don't know why I had this fixed idea to apply eval() before shuffling it. The shuffle works perfect for character vectors, to which I can directly apply concat(). (otherwise, the concat() on integer vectors will return the vector itself).

Code:
gp > cnt=0; while(cnt<20,w=vecextract(v=Vec("9293392505711486960894715862"),numtoperm(#v,random((#v)!)));if(isprime(s=eval(concat(w))),print(s);cnt++))
5952959880393672096211164487
6965061212239814874935985907
7200418929249837815661659953
2116560389405997673981548229
3409512847521602869957913869
8839514176794286951009295263
9640322651819219357960884759
4261058231699196207954889357
6933576251126798800918925449
1858545261027969938971642093
2854968812303119755667409929
5097678924618962542518319903
7105339812269507952894468691
5102659546293698929031841787
6923988910519227637464815059
4959164579896327018522130689
7868523014995425271099686931
2326894160625038947598711599
9938170966151296594035482827
2956882154260045399116979837
time = 137 ms.
gp >
.
Brilliant huh?
(cheating too, I had to run it 4-5 times to get a lower running time and 20 primes which have no leading zeros, hehe)

Last fiddled with by LaurV on 2016-03-16 at 04:55
LaurV is offline   Reply With Quote