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.

A004757 Binary expansion starts 101.

This page as a plain text file.
%I A004757 #29 Jul 14 2022 02:36:17
%S A004757 5,10,11,20,21,22,23,40,41,42,43,44,45,46,47,80,81,82,83,84,85,86,87,
%T A004757 88,89,90,91,92,93,94,95,160,161,162,163,164,165,166,167,168,169,170,
%U A004757 171,172,173,174,175,176,177,178,179,180,181,182,183,184,185
%N A004757 Binary expansion starts 101.
%H A004757 Reinhard Zumkeller, <a href="/A004757/b004757.txt">Table of n, a(n) for n = 1..4095</a>
%F A004757 a(2n) = 2a(n), a(2n+1) = 2a(n) + 1 + 4*[n==0].
%F A004757 a(n) = n + 4 * 2^floor(log_2(n)) = A004756(n) + A053644(n).
%F A004757 a(2^m+k) = 5*2^m + k, m >= 0, 0 <= k < 2^m. - _Yosu Yurramendi_, Aug 08 2016
%e A004757 22 in binary is 10110, so 22 is in sequence.
%t A004757 Table[n + 4*2^Floor@ Log2@ n, {n, 57}] (* or *)
%t A004757 w = {1, 0, 1}; Select[Range[5, 185], If[# < 2^(Length@ w - 1), True, Take[IntegerDigits[#, 2], Length@ w] == w] &] (* _Michael De Vlieger_, Aug 10 2016 *)
%t A004757 Select[Range[5,200],Take[IntegerDigits[#,2],3]=={1,0,1}&] (* _Harvey P. Dale_, Aug 26 2016 *)
%o A004757 (PARI) a(n)=n+4*2^floor(log(n)/log(2))
%o A004757 (Haskell)
%o A004757 import Data.List (transpose)
%o A004757 a004757 n = a004757_list !! (n-1)
%o A004757 a004757_list = 5 : concat (transpose [zs, map (+ 1) zs])
%o A004757                    where zs = map (* 2) a004757_list
%o A004757 -- _Reinhard Zumkeller_, Dec 04 2015
%o A004757 (Python)
%o A004757 def A004757(n): return n+(2<<n.bit_length()) # _Chai Wah Wu_, Jul 13 2022
%Y A004757 Cf. A004754 (10), A004755 (11), A004756 (100), A004758 (110), A004759 (111).
%Y A004757 Cf. A004760, A053644, A062050, A076877.
%K A004757 nonn,base,easy
%O A004757 1,1
%A A004757 _N. J. A. Sloane_
%E A004757 Edited by _Ralf Stephan_, Oct 12 2003