Prime Numbers
Posted: Wed Jun 06, 2012 10:37 pm
I came across this algorithm recently, and it seems only fair to let everyone else who may be interested have a look at it:
I've got some nice Carmichael numbers around here somewhere
Enjoy.
Code: Select all
isPrime←{⌊(1+⌊3÷⍵)÷1++/⌊(k÷⍵)×⌊⍵÷k←1+2×(~⎕IO)+⍳⌊0.5×1+⍵*0.5}
isPrime¨3 5 7 9 11 13 15 17 19 21 23 25 27 29
1 1 1 0 1 1 0 1 1 0 1 0 0 1
is_Prime 9746347772161
1
I've got some nice Carmichael numbers around here somewhere
Code: Select all
isPrime¨1105 1729 2465 2821 6601 8911
0 0 0 0 0 0
Enjoy.