login
A386406
Length of the preperiodic part of the decimal expansion of 1/n, including any leading zeros from the period.
2
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,3
COMMENTS
See A114205.
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
EXAMPLE
For n = 92, 1/n = 0.01(0869565217391304347826) = 0.010(8695652173913043478260), so the preperiodic part is "010" and has length a(92) = 3.
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}]
PROG
(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
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Andrei Zabolotskii, Jul 20 2025
STATUS
approved