How to resolve the algorithm Carmichael 3 strong pseudoprimes step by step in the F# programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Carmichael 3 strong pseudoprimes step by step in the F# programming language

Table of Contents

Problem Statement

A lot of composite numbers can be separated from primes by Fermat's Little Theorem, but there are some that completely confound it. The   Miller Rabin Test   uses a combination of Fermat's Little Theorem and Chinese Division Theorem to overcome this. The purpose of this task is to investigate such numbers using a method based on   Carmichael numbers,   as suggested in   Notes by G.J.O Jameson March 2010.

Find Carmichael numbers of the form: where   (Prime1 < Prime2 < Prime3)   for all   Prime1   up to   61. (See page 7 of   Notes by G.J.O Jameson March 2010   for solutions.)

For a given

P r i m

e

1

{\displaystyle Prime_{1}}

Chernick's Carmichael numbers

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Carmichael 3 strong pseudoprimes step by step in the F# programming language

Source code in the fsharp programming language

// Carmichael Number . Nigel Galloway: November 19th., 2017
let fN n = Seq.collect ((fun g->(Seq.map(fun e->(n,1+(n-1)*(n+g)/e,g,e))){1..(n+g-1)})){2..(n-1)}
let fG (P1,P2,h3,d) =
  let mod' n g = (n%g+g)%g
  let fN P3 = if isPrime P3 && (P2*P3)%(P1-1)=1 then Some (P1,P2,P3) else None
  if isPrime P2 && ((h3+P1)*(P1-1))%d=0 && mod' (-P1*P1) h3=d%h3 then fN (1+P1*P2/h3) else None
let carms g = primes|>Seq.takeWhile(fun n->n<=g)|>Seq.collect fN|>Seq.choose fG
carms 61 |> Seq.iter (fun (P1,P2,P3)->printfn "%2d x %4d x %5d = %10d" P1 P2 P3 ((uint64 P3)*(uint64 (P1*P2))))


  

You may also check:How to resolve the algorithm Bulls and cows step by step in the Smalltalk programming language
You may also check:How to resolve the algorithm URL decoding step by step in the Yabasic programming language
You may also check:How to resolve the algorithm Modular exponentiation step by step in the Tcl programming language
You may also check:How to resolve the algorithm Read a file line by line step by step in the CLU programming language
You may also check:How to resolve the algorithm Five weekends step by step in the AutoIt programming language