Cyclic Number

Author

Eric W. Weisstein
August 29, 2003

This notebook downloaded from http://mathworld.wolfram.com/notebooks/NumberTheory/CyclicNumber.nb.

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

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

Additional Authors

Counts up to (10^7)and (10^8)by 
Jud McCranie, Ed Pegg Jr., and Eric Weisstein
August 29, 2003

Initialization

<<Digits`

DigitCycleLength[r_Rational,b_Integer?Positive]:=MultiplicativeOrder[b,FixedPoint[Quotient[#,GCD[#,b]]&,Denominator[r]]];

DigitCycleLength[1/7,10]

MultiplicativeOrder

Do[If[Prime[n]-DigitCycleLength[1/Prime[n],10]==1,a++],{n,2,PrimePi[10^7]}]
Print[a]

cyclicNumberQ[n_]:=MultiplicativeOrder[10,FixedPoint[Quotient[#,GCD[#,10]]&,n]]==n-1

cyclicNumberQ[8]

Table

full=Select[Prime[Range[20]],PrimitiveRootQ[10,#]&]

(TraditionalForm[DecimalExpansion[#]]&/@(1/full))//ColumnForm

PrimitiveRootQ[10,17389]

Fraction

Select[Prime[Range[PrimePi[10^2]]],CyclicNumberQ]

(l=Table[Count[Prime[Range[PrimePi[10^n]]],_?CyclicNumberQ],{n,6}])//Timing

(l=Table[Count[Prime[Range[PrimePi[10^n]]],_?CyclicNumberQ],{n,7}])//Timing

(l=Table[Count[Prime[Range[PrimePi[10^n]]],_?CyclicNumberQ],{n,8}])//Timing

(l=Table[Count[Prime[Range[PrimePi[10^n]]],_?CyclicNumberQ],{n,9}])//Timing

PCT

Rest[FoldList[Plus,0,{29500,219381,1906407,16861329,151152624}]]

7: 39. Second
8: 195. Second
9: 1065. Second
10: 52355. Second

l={1,9,60,467,3617,29500,248881,2155288,19016617,170169241};

Plot

f=N[MapIndexed[#1/PrimePi[10^First[#2]]&,l],10]

<<Graphics`Colors`

ArtinC=0.3739558136;

ListPlot[f,PlotStyle->Red,PlotJoined->True,Epilog->{Red,PointSize[.02],MapIndexed[Point[{#2[[1]],#1}]&,f],
Dashing[{.02}],Blue,Line[{{1,#},{10,#}}]&[ArtinC]
},
PlotRange->{.35,.381},AxesOrigin->{1,.35},
AxesLabel->TraditionalForm/@{n,F[10^n]}
]

Cyclic Part

FromDigits/@CyclicPart/@(1/full)