A386406 Length of the preperiodic part of the decimal expansion of 1/n, including any leading zeros from the period.
1, 0, 2, 1, 1, 0, 3, 0, 1, 1, 2, 1, 1, 1, 4, 1, 1, 1, 2, 1, 1, 1, 3, 2, 1, 1, 2, 1, 1, 1, 5, 1, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 4, 1, 2, 1, 2, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 6, 1, 1, 1, 2, 1, 1, 1, 3, 1, 1, 2, 2, 1, 1, 1, 4, 1, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 3
Offset: 2
Examples
For n = 92, 1/n = 0.01(0869565217391304347826) = 0.010(8695652173913043478260), so the preperiodic part is "010" and has length a(92) = 3.
Programs
-
Mathematica
b[n_] := Block[{p,o}, {p,o} = RealDigits[1/n]; If[!IntegerQ[Last[p]], p = Join[Most[p],TakeWhile[Last[p],#==0&]]]; Length[p]-o]; Table[b[n], {n,2,100}]
-
PARI
a(n) = my(pre = max(valuation(n,2),valuation(n,5)), r = 10^pre % n); pre + if(r,logint(n\r,10)); \\ Kevin Ryde, Jul 22 2025
Formula
a(n) = p + (floor(log_10(1/f)) if f!=0), where p = A051628(n) and f = frac(10^p/n). - Kevin Ryde, Jul 22 2025
Comments