login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A030308 Triangle T(n,k): Write n in base 2, reverse order of digits, to get the n-th row. 194

%I

%S 0,1,0,1,1,1,0,0,1,1,0,1,0,1,1,1,1,1,0,0,0,1,1,0,0,1,0,1,0,1,1,1,0,1,

%T 0,0,1,1,1,0,1,1,0,1,1,1,1,1,1,1,0,0,0,0,1,1,0,0,0,1,0,1,0,0,1,1,1,0,

%U 0,1,0,0,1,0,1,1,0,1,0,1,0,1,1,0,1,1,1,1,0,1

%N Triangle T(n,k): Write n in base 2, reverse order of digits, to get the n-th row.

%C This is the quite common, so-called "bittest" function, see Pari code. - _M. F. Hasler_, Jul 21 2013

%C For a given number m and a digit position k the corresponding sequence index n can be calculated by n(m,k)=m*(1+floor(log_2(m)))-2^(1+floor(log_2(m)))+k+1. For example: counted from right to left, the second digit of m=13 (binary 1101) is '0'. Hence the sequence index is n=n(13,2)=39. - _Hieronymus Fischer_, May 05 2007

%C A070939(n) = length of n-th row; A000120(n) = sum of n-th row; A030101(n) = n-th row seen as binary number; A000035(n) = T(n,0). - _Reinhard Zumkeller_, Jun 17 2012

%H Reinhard Zumkeller, <a href="/A030308/b030308.txt">Rows n = 0..1023 of triangle, flattened</a>

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

%F a(n) = floor(m/2^(k-1)) mod 2, where m=max(j|A001855(j)<n) and k=n-A001855(m). - _Hieronymus Fischer_, May 05 2007, Sep 10 2007

%e Triangle begins :

%e 0

%e 1

%e 0, 1

%e 1, 1

%e 0, 0, 1

%e 1, 0, 1

%e 0, 1, 1

%e 1, 1, 1

%e 0, 0, 0, 1

%e 1, 0, 0, 1 - _Philippe Deléham_, Oct 12 2011

%p A030308_row := n -> op(convert(n,base, 2)):

%p seq(A030308_row(n), n=0..23); # _Peter Luschny_, Nov 28 2017

%t Flatten[Table[Reverse[IntegerDigits[n, 2]], {n, 0, 23}]] (* _T. D. Noe_, Oct 12 2011 *)

%o (Haskell)

%o a030308 n k = a030308_tabf !! n !! k

%o a030308_row n = a030308_tabf !! n

%o a030308_tabf = iterate bSucc [0] where

%o bSucc [] = [1]

%o bSucc (0 : bs) = 1 : bs

%o bSucc (1 : bs) = 0 : bSucc bs

%o -- _Reinhard Zumkeller_, Jun 17 2012

%o (PARI) A030308(n,k)=bittest(n,k) \\ Assuming that columns are numbered starting with k=0, as suggested by the formula from R. Zumkeller. - _M. F. Hasler_, Jul 21 2013

%o (Python) for n in xrange(0, 20): print list(map(int,str(bin(n)[2:])[::-1])) # _Indranil Ghosh_, Mar 31 2017

%o (Sage)

%o A030308_row = lambda n: n.bits() if n > 0 else [0]

%o for n in (0..23): print(A030308_row(n)) # _Peter Luschny_, Nov 28 2017

%Y Cf. A030190.

%Y Cf. A030341, A030386, A031235, A030567, A031007, A031045, A031087, A031298 for the base-3 to base-10 analogs.

%K nonn,base,easy,tabf

%O 0,1

%A _Clark Kimberling_

%E Initial 0 and better name by _Philippe Deléham_, Oct 12 2011

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

License Agreements, Terms of Use, Privacy Policy .

Last modified February 23 23:56 EST 2018. Contains 299595 sequences. (Running on oeis4.)