Carmichael 3 strong pseudoprimes: Difference between revisions

m
tidy up task description
(Shorer D entry)
m (tidy up task description)
Line 1:
{{task}}
A lot of composite numbers can be detected by the [[Miller-Rabin primality test|Miller Rabin Test]], but there are some that evade it.
:Prime1The <purpose Prime2of <this Prime3task foris allto Prime1investigate uptosuch 61numbers seeusing pagea 7method ofbased on [[wp:Carmichael number|Carmichael numbers]], as suggested in [http://www.maths.lancs.ac.uk/~jameson/carfind.pdf Notes by G.J.O Jameson March 2010].
 
The purposeobjective is to find Carmichael numbers of thisthe taskform is<math>Prime_1 to\times investigatePrime_2 such\times numbers.Prime_3</math> The(where method<math>Prime_1 suggested< isPrime_2 based< onPrime_3</math>) for all <math>Prime_1</math> up to 61 (see page 7 of [http://www.maths.lancs.ac.uk/~jameson/carfind.pdf Notes by G.J.O Jameson March 2010] for solutions).
 
'''Pseudocode:'''<br>For a given <math>Prime_1</math>
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].
 
<tt>for 1 < h3 < Prime<sub>1</sub></tt>
For a given Prime1
:<tt>g=h3+Prime<sub>1</sub></tt>
 
:<tt>for 10 < h3d < Prime1h3+Prime<sub>1</sub></tt>
::<tt>if (h3+Prime1Prime<sub>1</sub>)*(Prime1Prime<sub>1</sub>-1) mod d == 0 and -Prime1Prime<sub>1</sub> squared mod h3 == d mod h3</tt>
:g=h3+Prime1
::<tt>then</tt>
:for 0 < d < h3+Prime1
:::<tt>Prime<sub>2</sub> = 1 + ((Prime<sub>1</sub>-1) * g/d)</tt>
::if (h3+Prime1)*(Prime1-1) mod d == 0 and -Prime1 squared mod h3 == d mod h3
:::<tt>next d if Prime3Prime<sub>2</sub> is not prime</tt>
::then
:::<tt>Prime<sub>3</sub> = 1 + (Prime<sub>1</sub>*Prime<sub>2</sub>/h3)</tt>
:::Prime2 = 1 + ((Prime1-1) * g/d)
:::<tt>next d if Prime2Prime<sub>3</sub> is not prime</tt>
:::<tt>next d if (Prime<sub>2</sub>*Prime<sub>3</sub>) mod (Prime<sub>1</sub>-1) not equal 1</tt>
:::Prime3 = 1 + (Prime1*Prime2/h3)
:::<tt>Prime<sub>1</sub> * Prime<sub>2</sub> * Prime<sub>3</sub> is a Carmichael Number</tt>
:::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
 
Related Tasks:
:[http://rosettacode.org/wiki/Miller-Rabin_primality_test Miller-Rabin primality test]
 
<br><br>
 
=={{header|D}}==
Line 140 ⟶ 133:
 
=={{header|Haskell}}==
 
{{trans|Ruby}}
{{libheader|primes}}
{{Works with|GHC|7.4.1}}
{{Works with|primes|0.2.1.0}}
 
<lang haskell>#!/usr/bin/runhaskell
 
Line 173 ⟶ 164:
 
main = putStr $ unlines $ map show carmichaels</lang>
 
{{out}}
 
<pre>
(3,11,17)
Line 600 ⟶ 589:
 
=={{header|Ruby}}==
<lang ruby># Generate Charmichael Numbers
# Generate Charmichael Numbers
#
# Nigel_Galloway
Line 621 ⟶ 609:
}
puts ""
}</lang>
}
</lang>
{{out}}
<pre style="height:30ex;overflow:scroll">
Anonymous user