cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A088995 Least k > 0 such that the first n digits of 2^k and 5^k are identical.

Original entry on oeis.org

5, 98, 1068, 1068, 127185, 2728361, 15917834, 73482154, 961700165, 961700165, 83322853582, 1404948108914, 7603192018819, 167022179253602, 3550275020220728, 5729166542536373, 106675272785875442, 331484151442699072, 2330288635428230258177, 2330288635428230258177
Offset: 1

Views

Author

Lekraj Beedassy, Dec 01 2003

Keywords

Comments

The number of matching first digits of 2^n and 5^n increases with n and forms the sequence 3,1,6,2,2,7,7,6,6,... which approaches sqrt(10).
Numbers are half of the denominator of some convergent to log_10(2). - J. Mulder (jasper.mulder(AT)planet.nl), Feb 03 2010 [WARNING: This holds only for n < 6, it is wrong from a(6) = 2728361 on: The denominators are ..., 325147, 6107016, ... which would yield the larger solution 3053508 for n = 6. - M. F. Hasler, Mar 20 2025]
Xianwen Wang guesses that if the length of the continued fraction of m/k is h (where m is the difference between the numbers of digits of 2^k and 5^k), the first h-1 items of the continued fractions of m/k and log_10(2.5) agree. But this guess is not true for the similar sequence A359698. - Zhao Hui Du, Jun 06 2023
The terms grow like 10^n, oscillating by a few orders of magnitude around this value. I conjecture that log(a(n)/10^n) = O(log log n). - M. F. Hasler, Mar 22 2025

Examples

			a(2) = 98: 2^98 = 316912650057057350374175801344 and 5^98 = 315544362088404722164691426113114491869282574043609201908111572265625.
		

Crossrefs

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)=a3, 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