login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A038585 Write n in binary, delete 0's. 3

%I #28 May 19 2020 13:08:41

%S 1,1,11,1,11,11,111,1,11,11,111,11,111,111,1111,1,11,11,111,11,111,

%T 111,1111,11,111,111,1111,111,1111,1111,11111,1,11,11,111,11,111,111,

%U 1111,11,111,111,1111,111,1111,1111,11111,11,111,111,1111,111,1111,1111

%N Write n in binary, delete 0's.

%H Vincenzo Librandi, <a href="/A038585/b038585.txt">Table of n, a(n) for n = 1..1000</a>

%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>

%F a(n) = (9 * n mod 2 + 1) * a(floor(n/2)) + n mod 2. - _Reinhard Zumkeller_, Oct 10 2012

%F a(n) = A002275(A000120(n)). - _Chai Wah Wu_, May 19 2020

%t Table[FromDigits[DeleteCases[IntegerDigits[n,2],_?(#==0&)]],{n,60}] (* _Harvey P. Dale_, Feb 27 2012 *)

%t FromDigits/@(IntegerDigits[Range[60],2]/.(0->Nothing)) (* _Harvey P. Dale_, Apr 09 2017 *)

%o (Haskell)

%o a038585 0 = 0

%o a038585 n = (9 * m + 1) * (a038585 n') + m where (n', m) = divMod n 2

%o -- _Reinhard Zumkeller_, Oct 10 2012

%o (Python)

%o def A038585(n):

%o return int(bin(n)[2:].replace('0','')) # _Chai Wah Wu_, May 19 2020

%Y Cf. A000120, A002275, A038573.

%K nonn,easy,base,nice

%O 1,3

%A _N. J. A. Sloane_

%E More terms from _Erich Friedman_

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 19 10:38 EDT 2024. Contains 371791 sequences. (Running on oeis4.)