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.

A018856 2^a(n) is the smallest power of 2 beginning with n.

This page as a plain text file.
%I A018856 #27 Jul 04 2023 15:07:14
%S A018856 0,1,5,2,9,6,46,3,53,10,50,7,17,47,77,4,34,54,84,11,31,51,61,81,8,18,
%T A018856 38,48,68,78,98,5,25,35,45,55,75,85,95,12,22,32,42,145,52,62,72,82,92,
%U A018856 102,9,19,29,39,142,49,59,162,69,79,89,192,99,6,16,119,26
%N A018856 2^a(n) is the smallest power of 2 beginning with n.
%D A018856 A. M. Yaglom and I. M. Yaglom, Challenging Mathematical Problems With Elementary Solutions, Vol. 1, pp. 29, 199-200, Prob. 91a, Dover, NY, 1987.
%H A018856 Daniel Mondot, <a href="/A018856/b018856.txt">Table of n, a(n) for n = 1..32699</a>
%t A018856 f[n_] := Block[{k = 1, m = Floor[ Log[10, n]]}, While[ Log[10, 2^k] < Floor[ Log[10, n]], k++ ]; While[ Quotient[2^k, 10^(Floor[k*Log[10, 2]] - m)] != n, k++ ]; k]; f[1] = 0;; Array[f, 73] (* _Robert G. Wilson v_, Jun 02 2009 *)
%o A018856 (Haskell)
%o A018856 import Data.List (isPrefixOf, findIndex)
%o A018856 import Data.Maybe (fromJust)
%o A018856 a018856 n =
%o A018856    fromJust $ findIndex (show n `isPrefixOf`) $ map show a000079_list
%o A018856 -- _Reinhard Zumkeller_, Aug 04 2011
%o A018856 (Python)
%o A018856 from itertools import count
%o A018856 def aupton(terms):
%o A018856     adict, pow2 = dict(), 1
%o A018856     for i in count(0):
%o A018856         s = str(pow2)
%o A018856         for j in range(len(s)):
%o A018856             t = int(s[:j+1])
%o A018856             if t > terms:
%o A018856                 break
%o A018856             if t not in adict:
%o A018856                 adict[t] = i
%o A018856         if len(adict) == terms:
%o A018856             return [adict[i+1] for i in range(terms)]
%o A018856         pow2 *= 2
%o A018856 print(aupton(67)) # _Michael S. Branicky_, Apr 08 2023
%Y A018856 Cf. A018802.
%Y A018856 Cf. A100129 (a(n) = n).
%Y A018856 Cf. A030000, A000079.
%K A018856 nonn,base
%O A018856 1,3
%A A018856 _David W. Wilson_