Creating Carmichael NumberA tool for teachers\302\2512007 by Mike May, S.J., Saint Louis University - maymk@slu.eduThis worksheet is a tool for teachers to let them easily generate Carmichael numbers to use for examples.restart:The literature notes that if p is prime and 6p+1, 12p+1, and 18p+1 are all prime, then(6p+1)(12p+1)(18p+1) is a Carmichael number.This makes it easy to generate Carmichael numbers of a given size.FindCarmichael := proc(StartKey)
local BaseP, p, n:
BaseP := floor(evalf((StartKey/(6*12*18))^(1/3))):
p := nextprime(BaseP):
while (not( (isprime(6*p+1)) and (isprime(12*p+1))
and (isprime(18*p+1)) )) do
p:= nextprime(p):
end do:
n:= (6*p+1)*(12*p+1)*(18*p+1):
[BaseP, p, p-BaseP, n];
end proc:FindCarmichael(10^5);This does not find small Carmichael numbers, but once it gets started it finds numbers that are close in ratio.Current := FindCarmichael(1);
for i from 1 to 10 do
Current := FindCarmichael(Current[4]);
end do;If we start with a base of about 10^40, we see that these numbers are rare in absolute terms, but close in terms of percent change from the base.Current := FindCarmichael(10^40);
for i from 1 to 10 do
Current := FindCarmichael(Current[4]);
end do;
With a slight variation we can find Carmichael numbers of a string of sizes.for i from 1 to 15 do
FindCarmichael(10^(3*i+3));
FindCarmichael(rand(10^(3*i+3))());
end do;Legal Notice: The copyright for this application is owned by the author(s). Neither Maplesoft nor the author are responsible for any errors contained within and are not liable for any damages resulting from the use of this material. This application is intended for non-commercial, non-profit use only. Contact the author for permission if you wish to use this application in for-profit activities.