Carmichael Function

Author

Eric W. Weisstein
July 5, 2009

This notebook downloaded from http://mathworld.wolfram.com/notebooks/NumberTheoreticFunctions/CarmichaelFunction.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/CarmichaelFunction.html.

©2009 Wolfram Research, Inc. except for portions noted otherwise

Intialization

Code

MyCarmichaelLambda[1]:=1
MyCarmichaelLambda[n_]:=LCM@@Map[(#1[[1]]-1)#1[[1]]^(#1[[2]]-1)&,FactorInteger[n]]

lambda[1]:=1
lambda[n_]:=Module[{f=FactorInteger[n],p,a},
If[Length[f]==1,{p,a}=f[[1]]];
Which[
Length[f]==1&&((p==2&&a≤2)||p≥3),EulerPhi[n],
Length[f]==1&&p==2&&a≥3,EulerPhi[n]/2,
True,LCM@@(lambda/@(Power@@@f))
]
]

Table

Table[CarmichaelLambda[n],{n,20}]

Table[MyCarmichaelLambda[n],{n,20}]

Table[lambda[n],{n,20}]

Identities

(CarmichaelLambda[(2^r)])==(Piecewise[{{1, r==0∨r==1}, {2, r==2}, {(2^(r-2)), True}}])

Table[CarmichaelLambda[2^n],{n,0,10}]

Table[Piecewise[{{1,r==0||r==1},{2,r==2}},(2^(r-2))],{r,0,10}]

(CarmichaelLambda[n!])==(Piecewise[{{1, n==1∨n==2}, {2, n==3}, {4, n==5}, {((n!)/(2 (n#))), True}}])

Table[CarmichaelLambda[n!],{n,20}]

Table[((n!)/(2Primorial[n])),{n,20}]

Table[Piecewise[{{1,n==1||n==2},{2,n==3},{4,n==5}},((n!)/(2Primorial[n]))],{n,20}]