Carmichael 3 strong pseudoprimes: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 5:
 
The objective is to find Carmichael numbers of the form Prime1 X Prime2 X Prime3.
:Prime1 < Prime2 < Prime3 for all Prime1 upto 61 see page 7 of [http://www.maths.lancs.ac.uk/~jameson/carfind.pdf Notes by G.J.O Jameson March 2010].
 
For a given Prime1
 
for 1 < h3 < Prime1
:for 0 < d < h3+Prime1
::if (h3+Prime1)*(Prime1-1) mod d == 0 and -Prime1 squared mod h3 == d mod h3
::then
:::Prime2 = 1 + ((Prime1-1) * g/d)
:::next d if Prime2 is not prime
:::Prime3 = 1 + (Prime1*Prime2/h3)
:::next d if Prime3 is not prime
:::next d if (Prime2*Prime3) mod (Prime1-1) not equal 1
:::Prime1 * Prime2 * Prime3 is a Carmichael Number
 
=={{header|Ruby}}==
2,172

edits