gives the Carmichael function
.
CarmichaelLambda
gives the Carmichael function
.
Details
- CarmichaelLambda is also known as the reduced totient function or the least universal exponent function.
- CarmichaelLambda is typically used in primality testing to find a composite number that cannot be proved composite by some primality tests.
- Integer mathematical function, suitable for both symbolic and numerical manipulation.
- CarmichaelLambda[n] is the smallest positive integer
such that
for all
relatively prime to
. - For a number
with
a unit and
primes, CarmichaelLambda[n] returns LCM[(p1-1)
,…,(pm-1)
].
Examples
open all close allBasic Examples (2)
Compute CarmichaelLambda of
:
CarmichaelLambda[10]DiscretePlot[CarmichaelLambda[n], {n, 0, 50}]Scope (7)
Numerical Evaluation (4)
CarmichaelLambda[10]CarmichaelLambda[-10]CarmichaelLambda[10 ^ 90 + 1]CarmichaelLambda threads over lists:
CarmichaelLambda[{2, 4, 7}]TraditionalForm formatting:
CarmichaelLambda[n]//TraditionalFormSymbolic Manipulation (3)
Find an integer solution instance:
FindInstance[CarmichaelLambda[n] == EulerPhi[n] && n > 0, n, Integers]FullSimplify[Mod[a ^ CarmichaelLambda[n], n], Element[a | n, Integers] && GCD[a, n] == 1 && n > 1]Identify the CarmichaelLambda sequence:
FindSequenceFunction[{1, 1, 2, 2, 4, 2, 6, 2, 6, 4}, n]Applications (7)
Basic Applications (3)
The first 20 values of CarmichaelLambda:
Grid[{Prepend[Range[20], "n"], Prepend[Table[CarmichaelLambda[n], {n, 20}], "TraditionalFormλ(n)"]}, Background -> {None, {Orange, StandardGray}}, Dividers -> Lighter[Gray, .5], Spacings -> {Automatic, .8}]DiscretePlot[CarmichaelLambda[n], {n, 0, 100}]NumberLinePlot[Table[CarmichaelLambda[n], {n, 100}]]CarmichaelGF[z_] := Sum[CarmichaelLambda[n] * z ^ n, {n, 500}]GraphicsRow[{Plot[CarmichaelGF[x], {x, 0, 1}], ContourPlot[Re[CarmichaelGF[x + I * y]], {x, -1, 1}, {y, -1, 1}, ContourStyle -> None]}]Exponential generating function:
CarmichaelEGF[z_] := Sum[CarmichaelLambda[n] * z ^ n / n!, {n, 500}]GraphicsRow[{Plot[CarmichaelEGF[x], {x, 0, 5}], ContourPlot[Re[CarmichaelEGF[x + I * y]], {x, -3, 3}, {y, -3, 3}, ContourStyle -> None]}]CarmichaelDirichlet[s_] := Sum[CarmichaelLambda[n] / n ^ s, {n, 500}]GraphicsRow[{Plot[CarmichaelDirichlet[x], {x, 0, 1}], ContourPlot[Re[CarmichaelDirichlet[x + I * y]], {x, -1, 1}, {y, -1, 1}, ContourStyle -> None]}]Primality Testing (2)
Given a prime,
for all positive numbers a less than p:
Table[Mod[a ^ (11 - 1), 11] == 1, {a, 1, 10}]primeQ[n_, a_ : 2] := Mod[a ^ (n - 1), n] == 1{primeQ[3], primeQ[9], primeQ[23]}{primeQ[341, 2], primeQ[341, 3]}This test can be inconclusive for composite integers n satisfying
:
Mod[561, CarmichaelLambda[561]]primeQ[561, 2]Verify
for all a coprime to 561:
AllTrue[Select[Range[561], CoprimeQ[#, 561]&], primeQ[561, #]&]Recognize Carmichael numbers, composite numbers with an≡1 mod n for all a coprime to n:
CarmichaelNumberQ[n_] := CompositeQ[n] && Mod[n, CarmichaelLambda[n]] == 1The number
is a Carmichael number,
is not:
CarmichaelNumberQ[561]CarmichaelNumberQ[1310]Cryptography (1)
Build RSA-like encryption scheme. Start with the modulus:
{p, q} = Prime[RandomInteger[{10 ^ 4, 10 ^ 5}, {2}]];
n = p qFind the universal exponent of the multiplication group modulo n:
λ = CarmichaelLambda[n]d = NestWhile[#1 + 1&, Round[n / 3], GCD[λ, #1] =!= 1&]e = ModularInverse[d, λ]PowerMod[ToCharacterCode["RSA in Mathematica"], e, n]FromCharacterCode[PowerMod[%, d, n]]Number Theory (1)
Find the number of elements in the largest subgroup of Z_n^*:
FindCycles[n_] := Cases[GroupElements[CyclicGroup[EulerPhi[n]]], Cycles[{x_}] -> x]EulerPhi[12]subgroups = FindCycles[14]Dimensions[subgroups][[2]]CarmichaelLambda[12]Properties & Relations (7)
CarmichaelLambda[{-2, -1, 0, 1, 2}]{Divisible[24, 8], Divisible[CarmichaelLambda[24], CarmichaelLambda[8]]}The LCM of CarmichaelLambda is equal to CarmichaelLambda of the LCM:
{LCM@@CarmichaelLambda[{3, 8}], CarmichaelLambda[LCM[3, 8]]}If
is square-free then a≡aλ(n)+1mod n:
SquareFreeQ[17]Mod[3 ^ (CarmichaelLambda[17] + 1), 17]The multiplicative order of an element modulo
divides CarmichaelLambda[n]:
Divisible[CarmichaelLambda[9], MultiplicativeOrder[4, 9]]CarmichaelLambda divides EulerPhi:
Divisible[EulerPhi[8], CarmichaelLambda[8]]If
has a primitive root, then CarmichaelLambda and EulerPhi are the same:
Cases[Range[2, 20], n_ /; IntegerQ[PrimitiveRoot[n]]]CarmichaelLambda[%]EulerPhi[%%]Neat Examples (2)
A plot of varying CarmichaelLambda values:
ArrayPlot[Table[CarmichaelLambda[j + 5k], {j, 1, 100}, {k, 1, 100}], ColorFunction -> "AvocadoColors"]Ulam spiral where numbers are colored based on the values of CarmichaelLambda:
ulam[n_] := Partition[Permute[Range[n ^ 2], Accumulate[Take[Flatten[{{n ^ 2 + 1} / 2, Table
[(-1) ^ j i, {j, n}, {i, {-1, n}}, {j}]}], n ^ 2]]], n]ArrayPlot[CarmichaelLambda[ulam[101]], ColorFunction -> "Rainbow"]Tech Notes
Related Guides
Related Links
History
Introduced in 1999 (4.0) | Updated in 2018 (11.3)
Text
Wolfram Research (1999), CarmichaelLambda, Wolfram Language function, https://reference.wolfram.com/language/ref/CarmichaelLambda.html (updated 2018).
CMS
Wolfram Language. 1999. "CarmichaelLambda." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2018. https://reference.wolfram.com/language/ref/CarmichaelLambda.html.
APA
Wolfram Language. (1999). CarmichaelLambda. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CarmichaelLambda.html
BibTeX
@misc{reference.wolfram_2026_carmichaellambda, author="Wolfram Research", title="{CarmichaelLambda}", year="2018", howpublished="\url{https://reference.wolfram.com/language/ref/CarmichaelLambda.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_carmichaellambda, organization={Wolfram Research}, title={CarmichaelLambda}, year={2018}, url={https://reference.wolfram.com/language/ref/CarmichaelLambda.html}, note=[Accessed: 12-June-2026]}