A114206 Length of the preperiodic part of the decimal expansion of 1/n, and also leading zeros from the period part if the preperiodic digits are all 0s (if any).
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, 2, 1, 1, 1, 5, 1, 1, 1, 2
Offset: 2
Examples
For n = 11, 1/n = 0.(09), so the preperiodic part is empty and the initial 0 of the periodic part is included for length a(11) = 1. For n = 92, 1/n = 0.01(0869565217391304347826) , so the preperiodic part is "01" and has length a(92) = 2 and the initial 0 in the periodic part is not included since that preperiodic part is not all 0s (unlike the way A386406(92) = 3 does include that inat periodic initial 0).
Links
Programs
-
Mathematica
fb[n_] := Block[{rd, o, p},rd = RealDigits[1/n];o = Last[rd];p = First[rd];If[ ! IntegerQ[Last[p]], p = Most[p]];Length[p] - o];Table[fb[n], {n, 120}] (* Ray Chandler, Oct 18 2006 *) r[x_]:=RealDigits[1/x]; w[x_]:=First[r[x]]; f[x_]:=First[w[x]]; l[x_]:=Last[w[x]]; z[x_]:=Last[r[x]]; b[x_]:=Which[IntegerQ[l[x]], Length[w[x]]-1*z[x], IntegerQ[f[x]]==False, -1*z[x], True, Length[Drop[w[x],-1]]-1*z[x]]; (* Hans Havermann, Oct 18 2006 *) Table[b[i], {i,2,128}]
-
PARI
a(n) = max(logint(n,10), max(valuation(n,2), valuation(n,5))); \\ Kevin Ryde, Jul 22 2025
Formula
Extensions
More terms from Ray Chandler and Hans Havermann, Oct 18 2006
Edited by Andrei Zabolotskii and Kevin Ryde, Jul 20 2025
Comments