Carmichael numbers | R Documentation |
Checks whether a number is a Carmichael number.
carmichael(n)
n |
natural number |
A natural number n
is a Carmichael number if it is a Fermat
pseudoprime for every a
, that is a^(n-1) = 1 mod n
, but
is composite, not prime.
Here the Korselt criterion is used to tell whether a number n
is
a Carmichael number.
Returns TRUE or FALSE
There are infinitely many Carmichael numbers, specifically there should
be at least n^(2/7)
Carmichael numbers up to n (for n large enough).
R. Crandall and C. Pomerance. Prime Numbers - A Computational Perspective. Second Edition, Springer Science+Business Media, New York 2005.
primeFactors
carmichael(561) # TRUE ## Not run: for (n in 1:100000) if (carmichael(n)) cat(n, '\n') ## 561 2821 15841 52633 ## 1105 6601 29341 62745 ## 1729 8911 41041 63973 ## 2465 10585 46657 75361 ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.