A088995 Least k > 0 such that the first n digits of 2^k and 5^k are identical.
5, 98, 1068, 1068, 127185, 2728361, 15917834, 73482154, 961700165, 961700165, 83322853582, 1404948108914, 7603192018819, 167022179253602, 3550275020220728, 5729166542536373, 106675272785875442, 331484151442699072, 2330288635428230258177, 2330288635428230258177
Offset: 1
Examples
a(2) = 98: 2^98 = 316912650057057350374175801344 and 5^98 = 315544362088404722164691426113114491869282574043609201908111572265625.
Links
- Zhao Hui Du, Table of n, a(n) for n = 1..1000
- Zhao Hui Du, Chinese page to introduce algorithm for a(n) to prove the guess of _Xianwen Wang_
- Robert Munafo, Sequence A88995: The 32 and 3125 Property
- T. Sillke, Powers of 2 and 5 Puzzle
Programs
-
Mathematica
L2 = N[ Log[ 10, 2 ], 50 ]; L5 = N[ Log[ 10, 5 ], 50 ]; k = 1; Do[ While[ Take[ RealDigits[ 10^FractionalPart[ L2*k ] ][[ 1 ] ], n ] != Take[ RealDigits[ 10^FractionalPart[ L5*k ] ][[ 1 ] ], n ], k++ ]; Print[ k ], {n, 1, 10} ] L2 = N[ Log[ 10, 2 ], 50 ]; L5 = N[ Log[ 10, 5 ], 50 ]; k = 1; Do[ While[ Take[ RealDigits[ 10^FractionalPart[ L2*k ]][[ 1 ]], n ] != Take[ RealDigits[ 10^FractionalPart[ L5*k ]][[ 1 ]], n ], k++ ]; Print[ k ], {n, 1, 7} ] f[n_, k_] := {Floor[ 10^(k - 1 + N[FractionalPart[n Log[5]/Log[10]], 20])], Floor[10^(k - 1 + N[FractionalPart[n Log[2]/Log[10]], 20])]} Flatten@Block[{$MaxExtraPrecision = \[Infinity]}, Block[{l = Denominator /@ Convergents[Log10[2], 1000]}, Array[k \[Function] l[[Flatten@Position[f[ #/2, k] & /@ l, {x_, x_}, {1}, 1]]]/2, 20]]] (* J. Mulder (jasper.mulder(AT)planet.nl), Feb 03 2010 *) (* alternate program *) n = 100; $MaxExtraPrecision = n; ans = ContinuedFraction[Log10[5/2], n]; data = Denominator /@ Flatten[Table[ FromContinuedFraction[Join[ans[[1 ;; p - 1]], {#}]] & /@ Range[1, ans[[p]]], {p, 2, n}]]; sol = Select[Table[{k, a = N[FractionalPart[{k Log10[2], k Log10[5]}], n]; 10^a, b = RealDigits[10^a][[All, 1]]; LengthWhile[Range[Length[b[[1]]]], b[[1, #]] == b[[2, #]] &], 10^a . {-1, 1}, RealDigits[10^a . {-1, 1}][[-1]]}, {k, data}], Abs[#[[-2]]] < 1 &]; acc = Association[{}]; s = sol[[All, {1, 3}]]; For[i = 1, i < Length[s], i++, If[Lookup[acc, s[[i, 2]], 0] == 0, acc[s[[i, 2]]] = s[[i, 1]]]]; final = Rest[Sort[Normal[acc]]] /. Rule -> List; bcc = Association[{}]; For[i = Max[Keys[acc]], i >= Min[Keys[acc]], i--, j = i; While[Lookup[acc, j, 0] == 0 && j < Max[Keys[acc]], j++]; bcc[i] = acc[j]; j = i; While[bcc[j] >= bcc[j + 1], j++]; bcc[i] = Min[bcc[i], bcc[j]]]; bb = Rest[Sort[Normal[Reverse[bcc]]]] /. Rule -> List (* Xianwen Wang, Jun 02 2023 *)
-
PARI
apply( {A088995(n) = localprec(max(n/.4,38)); my(L1=log(10), L2=log(2)/L1, L5=1-L2, c=contfrac(L5-L2), T=sqrtint(10^(2*n-1)), a=log(T)/L1%1, b=log(T+1)/L1%1, d(x)=a
3, while(t(c-cv[i]), c-=cv[i]))+return(c))}, [1..15]) \\ - M. F. Hasler, Mar 22 2025 -
Python
# NOTE: Although sympy's frac() may give incorrect results in some cases, care has been taken to ensure there should be no issue here. - M. F. Hasler, Mar 26 2025 from sympy import S, sqrt, log, frac def A088995(n): T = 10**n//sqrt(10); prec = (n+9)/.4; cf = 'continued_fraction' L2, L5, a, b = (frac(log(x,10).n(prec)) for x in (2, 5, T, T+1)) L = []; test = lambda k: a < frac(k*L2) < b > frac(k*L5) > a for K in S(f"{cf}_convergents({cf}_iterator(log(5/2,10)))"): if test(k := K.q): # = K.denominator but K.denominator() in old versions for step in L[::-1]: while test(k - step): k -= step return k if k > 99: L.append(k) # M. F. Hasler, Mar 22 2025, edited Mar 26 2025 print(first30 := [A088995(n) for n in range(1,30)]) # M. F. Hasler, Mar 18 2025, edited Mar 24 2025, Mar 28 2025
Extensions
Edited by Robert G. Wilson v, Dec 02 2003
More terms from J. Mulder (jasper.mulder(AT)planet.nl), Feb 03 2010
a(6) and a(7) corrected by Keith F. Lynch, May 25 2023
a(11), a(13)-a(15), a(17) corrected by Zhao Hui Du, Jun 07 2023
Comments