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-2 of 2 results.

A030000 a(n) is the smallest nonnegative number k such that the decimal expansion of 2^k contains the string n.

Original entry on oeis.org

10, 0, 1, 5, 2, 8, 4, 15, 3, 12, 10, 40, 7, 17, 18, 21, 4, 27, 30, 13, 11, 18, 43, 41, 10, 8, 18, 15, 7, 32, 22, 17, 5, 25, 27, 25, 16, 30, 14, 42, 12, 22, 19, 22, 18, 28, 42, 31, 11, 32, 52, 9, 19, 16, 25, 16, 8, 20, 33, 33, 23, 58, 18, 14, 6, 16, 46, 24, 15, 34, 29, 21, 17, 30
Offset: 0

Views

Author

Keywords

Comments

a(n) is well-defined for all n, because 2^k can actually start with (not just contain) any finite sequence of digits without leading zeros. This follows from the facts that log_10(2) is irrational and that the set of fractional parts of n*x is dense in [0,1] if x is irrational. - Pontus von Brömssen, Jul 21 2021

Examples

			2^12 = 4096 is first power of 2 containing a 9, so a(9) = 12.
		

Crossrefs

Cf. A030001 (the actual powers of 2), A063565, A018856, A000079, A372044, A372045.
See also A321043.

Programs

  • Haskell
    import Data.List (isInfixOf, findIndex)
    import Data.Maybe (fromJust)
    a030000 n =
       fromJust $ findIndex (show n `isInfixOf`) $ map show a000079_list
    -- Reinhard Zumkeller, Aug 04 2011
    
  • Mathematica
    Table[ i=0; While[ StringPosition[ ToString[ 2^i ], ToString[ n ] ]=={}, i++ ]; i, {n, 0, 80} ]
    snn[n_]:=Module[{k=0},While[SequenceCount[IntegerDigits[2^k],IntegerDigits[n]]==0,k++];k]; Array[snn,100,0] (* Harvey P. Dale, Mar 16 2025 *)
  • PARI
    a(n) = {if (n==1, return (0)); my(k=1, sn = Str(n)); while (#strsplit(Str(2^k), sn) == 1, k++); k;} \\ Michel Marcus, Mar 06 2021
    
  • PARI
    apply( A030000(n)={n=Str(n);for(k=0,oo,#strsplit(Str(2^k),n)>1&& return(k))}, [0..99]) \\ Also allows to search for digit strings with leading zeros, e.g., "00" => k=53. - M. F. Hasler, Jul 11 2021
    
  • Python
    def a(n):
      k, strn = 0, str(n)
      while strn not in str(2**k): k += 1
      return k
    print([a(n) for n in range(74)]) # Michael S. Branicky, Mar 06 2021

Formula

a(n) <= A018856(n) for n >= 1. - Pontus von Brömssen, Jul 21 2021

Extensions

More terms from Hans Havermann

A372044 Records in A030000.

Original entry on oeis.org

10, 15, 40, 43, 52, 58, 66, 111, 114, 136, 170, 171, 196, 215, 271, 286, 383, 519, 571, 611, 756, 758, 809, 1651, 1889, 2234, 2560, 2750, 3153, 5078, 5126, 5876, 6075, 6382, 6472, 8531, 8876, 9112, 9598, 14847, 17085, 17300, 17700, 20964, 26478, 28019, 28459, 28964, 32407, 32804
Offset: 1

Views

Author

Paolo Xausa, Apr 17 2024

Keywords

Examples

			From _David A. Corneth_, Apr 17 2024: (Start)
10 is in the sequence as A030000(0) = 10.
15 is the next term after 10 as the next record in A030000 occurs at k = 7 and A030000(7) = 15. (End)
		

Crossrefs

Programs

  • Mathematica
    d2k[k_] := d2k[k] = IntegerString[2^k];
    A030000[n_] := Block[{d = IntegerString[n], k = -1}, While[StringFreeQ[d2k[++k], d]]; k];
    Block[{upto = 10000, n = -1, a, r = -1}, Reap[While[++n <= upto, If[(a = A030000[n]) > r, Sow[r = a]]]][[2,1]]]
  • PARI
    \\ See PARI link

Extensions

More terms from David A. Corneth, Apr 17 2024
Showing 1-2 of 2 results.