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.

Showing 1-3 of 3 results.

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

A358196 Numbers k such that 5^k and 8^k have the same leading digit.

Original entry on oeis.org

0, 5, 9, 15, 19, 29, 34, 39, 44, 49, 54, 59, 98, 102, 108, 112, 118, 122, 132, 137, 142, 147, 152, 162, 191, 195, 201, 205, 211, 215, 225, 230, 235, 240, 245, 250, 255, 284, 294, 298, 304, 308, 318, 328, 333, 338, 343, 348, 387, 391, 397, 401, 407, 411, 421, 426, 431, 436, 441, 446, 451, 480, 490, 494, 500
Offset: 1

Views

Author

Nicolay Avilov, Nov 02 2022

Keywords

Comments

Write lg = log_10, let {x} denote the fractional part of x. Note that {k*lg(5)} = 1 - {k*lg(2)} and that {k*lg(8)} = {k*lg(2)} + 0, 1, or 2, so we have {k > 0 : 5^k and 8^k both start with a} = {k: {k*lg(2)} is in I_a}, where I_a = (1-lg(a+1), 1-lg(a)) intersect (((lg(a))/3, (lg(a+1))/3) U ((lg(a)+1)/3, (lg(a+1)+1)/3) U ((lg(a)+2)/3, (lg(a+1)+2)/3)). Note that I_1 = (1-lg(2), (lg(2)+2)/3), I_3 = ((lg(3)+1)/3, 1-lg(3)), I_5 = (lg(5)/3, lg(6)/3) and that I_a is empty otherwise. As a result, k > 0 is a term if and only if {k*lg(2)} is in (lg(5)/3, lg(6)/3) U ((lg(3)+1)/3, 1-lg(3)) U (1-lg(2), (lg(2)+2)/3). We see that when 5^k and 8^k both start with 1, 3, or 5, 2^k starts with 5, 3, or 1 respectively. - Jianing Song, Dec 26 2022

Examples

			5 is a term because 5^5 = 3125 and 8^5 = 32768;
9 is a term because 5^9 = 1953125 and 8^9 = 134217728.
		

Crossrefs

Programs

  • Mathematica
    Select[Range[0, 500], Equal @@ IntegerDigits[{5, 8}^#][[;; , 1]] &] (* Amiram Eldar, Nov 02 2022 *)
  • PARI
    isok(k) = digits(5^k)[1] == digits(8^k)[1]; \\ Michel Marcus, Nov 02 2022
    
  • Python
    def ok(n): return str(5**n)[0] == str(8**n)[0]
    print([k for k in range(501) if ok(k)]) # Michael S. Branicky, Nov 03 2022

A358197 Numbers k such that 2^k, 5^k and 8^k have the same first digit.

Original entry on oeis.org

0, 5, 15, 98, 108, 118, 191, 201, 211, 284, 294, 304, 387, 397, 407, 480, 490, 500, 583, 593, 603, 676, 686, 696, 779, 789, 872, 882, 892, 965, 975, 985, 1068, 1078, 1088, 1161, 1171, 1181, 1264, 1274, 1284, 1357, 1367, 1377, 1450, 1460, 1470, 1553, 1563, 1573, 1646, 1656, 1666
Offset: 1

Views

Author

Keywords

Comments

The first digit of 2^k is A008952(k) = floor(10^{k*log_10(2)}), the first digit of 5^k is A111395(k) = floor(10^{k*log_10(5)}), and the first digit of 8^k is A008952(3*k) = floor(10^{k*log_10(8)}), where "{x}" denotes the fractional part of x.
All numbers 2^k, 5^k, 8^k for k = a(n) > 0 start only with 3.
From Jianing Song, Dec 26 2022: (Start)
Write lg = log_10. Note that {k*lg(5)} = 1 - {k*lg(2)} and that {k*lg(8)} = {k*lg(2)} + 0, 1, or 2, so we have {k > 0 : 2^k, 5^k, 8^k all start with a} = {k: {k*lg(2)} is in I_a}, where I_a = (lg(a), lg(a+1)) intersect (1-lg(a+1), 1-lg(a)) intersect (((lg(a))/3, (lg(a+1))/3) U ((lg(a)+1)/3, (lg(a+1)+1)/3) U ((lg(a)+2)/3, (lg(a+1)+2)/3)). Note that I_3 = ((lg(3)+1)/3, 1-lg(3)) and I_a is empty otherwise (since (lg(a), lg(a+1)) intersect (1-lg(a+1), 1-lg(a)) is empty). As a result, k > 0 is a term if and only if (lg(3)+1)/3 < {k*lg(2)} < 1-lg(3).
Except for 0, also numbers k in A358196 such that 2^k starts with 3 (see the comment in A358196).
Claim: for n > 1, a(n+1) - a(n) = 10, 73, or 83. Proof: write a = (lg(3)+1)/3, b = 1-lg(3).
Step 1. If k > 0 is a term, then:
(a) {k*lg(2)} is in (a, b-(10*lg(2)-3)) => {(k+10)*lg(2)} is in (a+(10*lg(2)-3), b) => k+10 is a term;
(b) {k*lg(2)} is in (a+(25-83*lg(2)), b) => {(k+83)*lg(2)} is in (a, b-(25-83*lg(2))) => k+83 is a term.
Note that (a, b-(10*lg(2)-3)) U (a+(25-83*lg(2)), b) = (a, b), so at least one of k+10 and k+83 is a term.
Step 2. If k > 0 and k+m are both terms, 0 < m <= 83, then {k*lg(2)} and {(k+m)*lg(2)} are both in (a, b), so m*lg(2) is the range (N-(b-a), N+(b-a)) for some integer N, which implies that m = 10, 20, 73, or 83.
Note that if {k*lg(2)} < 1 - 2*(10*lg(2)-3), then {(k+10)*lg(2)} = {k*lg(2)} + (10*lg(2)-3), {(k+20)*lg(2)} = {k*lg(2)} + 2*(10*lg(2)-3), so {k*lg(2)} < {(k+10)*lg(2)} < {(k+20)*lg(2)}, which means that if k and k+20 are both terms, so is k+10. This shows that the next term after k is either 10, 73, or 83 larger.
We can show similarly that, for k > 0 being a term of this sequence:
(a) if k+73 is a term, then k+83 is a term;
(b) if k+83 is a term, then k+93 is a term;
(c) if k+166 is a term, then k+73 is a term;
(d) if k+10, k+73 are not terms (i.e., the next term is k+83), then k+176, k+196 are terms.
As a result, if we write out the sequence of the first differences, 73 is always followed by two 10's, and 83 is followed by one or two 10's; 83, 10, 10 is always followed by 73, 10, 10, and 83, 10 is always followed by 83, 10, 10. (End)

Examples

			5 is a term because the first digit of 2^5 = 32, 5^5 = 3125, 8^5 = 32768 is 3.
15 is a term because the first digit of 2^15 = 32768, 5^15 = 30517578125, 8^15 = 35184372088832 is 3.
		

Crossrefs

Intersection of A088935 and A358196.

Programs

  • Maple
    ld:= n -> floor(n/10^ilog10(n)):filter:= proc(k) local d;
      d:= ld(2^k);
      ld(5^k) = d and ld(8^k) = d
    end proc:select(filter, [$0..2000]); # Robert Israel, Nov 02 2022
  • Mathematica
    Select[Range[0, 1666], Equal @@ IntegerDigits[{2, 5, 8}^#][[;; , 1]] &] (* Amiram Eldar, Nov 02 2022 *)
  • Python
    def ok(n): return str(2**n)[0] == str(5**n)[0] == str(8**n)[0]
    print([k for k in range(1667) if ok(k)]) # Michael S. Branicky, Nov 03 2022
Showing 1-3 of 3 results.