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

A102370 "Sloping binary numbers": write numbers in binary under each other (right-justified), read diagonals in upward direction, convert to decimal.

Original entry on oeis.org

0, 3, 6, 5, 4, 15, 10, 9, 8, 11, 14, 13, 28, 23, 18, 17, 16, 19, 22, 21, 20, 31, 26, 25, 24, 27, 30, 61, 44, 39, 34, 33, 32, 35, 38, 37, 36, 47, 42, 41, 40, 43, 46, 45, 60, 55, 50, 49, 48, 51, 54, 53, 52, 63, 58, 57, 56, 59, 126, 93, 76, 71, 66, 65, 64, 67, 70, 69
Offset: 0

Views

Author

Philippe Deléham, Feb 13 2005

Keywords

Comments

All terms are distinct, but certain terms (see A102371) are missing. But see A103122.
Trajectory of 1 is 1, 3, 5, 15, 17, 19, 21, 31, 33, ..., see A103192.

Examples

			........0
........1
.......10
.......11
......100
......101
......110
......111
.....1000
.........
The upward-sloping diagonals are:
0
11
110
101
100
1111
1010
.......
giving 0, 3, 6, 5, 4, 15, 10, ...
The sequence has a natural decomposition into blocks (see the paper): 0; 3; 6, 5, 4; 15, 10, 9, 8, 11, 14, 13; 28, 23, 18, 17, 16, 19, 22, 21, 20, 31, 26, 25, 24, 27, 30; 61, ...
Reading the array of binary numbers along diagonals with slope 1 gives this sequence, slope 2 gives A105085, slope 0 gives A001477 and slope -1 gives A105033.
		

Crossrefs

Related sequences (1): A103542 (binary version), A102371 (complement), A103185, A103528, A103529, A103530, A103318, A034797, A103543, A103581, A103582, A103583.
Related sequences (2): A103584, A103585, A103586, A103587, A103127, A103192 (trajectory of 1), A103122, A103588, A103589, A103202 (sorted), A103205 (base 10 version).
Related sequences (3): A103747 (trajectory of 2), A103621, A103745, A103615, A103842, A103863, A104234, A104235, A103813, A105023, A105024, A105025, A105026, A105027, A105028.
Related sequences (4): A105029, A105030, A105031, A105032, A105033, A105034, A105035, A105108.

Programs

  • Haskell
    a102370 n = a102370_list !! n
    a102370_list = 0 : map (a105027 . toInteger) a062289_list
    -- Reinhard Zumkeller, Jul 21 2012
    
  • Maple
    A102370:=proc(n) local t1,l; t1:=n; for l from 1 to n do if n+l mod 2^l = 0 then t1:=t1+2^l; fi; od: t1; end;
  • Mathematica
    f[n_] := Block[{k = 1, s = 0, l = Max[2, Floor[Log[2, n + 1] + 2]]}, While[k < l, If[ Mod[n + k, 2^k] == 0, s = s + 2^k]; k++ ]; s]; Table[ f[n] + n, {n, 0, 71}] (* Robert G. Wilson v, Mar 21 2005 *)
  • PARI
    A102370(n)=n-1+sum(k=0,ceil(log(n+1)/log(2)),if((n+k)%2^k,0,2^k)) \\ Benoit Cloitre, Mar 20 2005
    
  • PARI
    {a(n) = if( n<1, 0, sum( k=0, length( binary( n)), bitand( n + k, 2^k)))} /* Michael Somos, Mar 26 2012 */
    
  • Python
    def a(n): return 0 if n<1 else sum([(n + k)&(2**k) for k in range(len(bin(n)[2:]) + 1)]) # Indranil Ghosh, May 03 2017

Formula

a(n) = n + Sum_{ k >= 1 such that n + k == 0 mod 2^k } 2^k. (Cf. A103185.) In particular, a(n) >= n. - N. J. A. Sloane, Mar 18 2005
a(n) = A105027(A062289(n)) for n > 0. - Reinhard Zumkeller, Jul 21 2012

Extensions

More terms from Benoit Cloitre, Mar 20 2005

A102371 Numbers missing from A102370.

Original entry on oeis.org

1, 2, 7, 12, 29, 62, 123, 248, 505, 1018, 2047, 4084, 8181, 16374, 32755, 65520, 131057, 262130, 524279, 1048572, 2097133, 4194286, 8388587, 16777192, 33554409, 67108842, 134217711, 268435428, 536870885
Offset: 1

Views

Author

Philippe Deléham, Feb 13 2005

Keywords

Comments

Indices of negative numbers in A103122.
Write numbers in binary under each other; start at 2^k, read in upward direction with the first bit omitted and convert to decimal:
. . . . . . . . . . 0
. . . . . . . . . . 1
.. . . . . . . . . 10 < -- Starting here, the upward diagonal (first bit omitted) reads 1 -> 1
.. . . . . . . . . 11
. . . . . . . . . 100 < -- Starting here, the upward diagonal (first bit omitted) reads 10 -> 2
. . . . . . . . . 101
. . . . . . . . . 110
. . . . . . . . . 111
.. . . . . . . . 1000 < -- Starting here, the upward diagonal (first bit omitted) reads 111 -> 7
. . . . . . . . .1001
Thus a(n) = A102370(2^n - n) - 2^n.
Do we have a(n) = 2^n-1-A105033(n-1)? - David A. Corneth, May 07 2020

Crossrefs

Programs

  • Haskell
    a102371 n = a102371_list !! (n-1)
    a102371_list = map (a105027 . toInteger) $ tail a000225_list
    -- Reinhard Zumkeller, Jul 21 2012
  • Maple
    A102371:= proc (n) local t1, l; t1 := -n; for l to n do if `mod`(n-l,2^l) = 0 then t1 := t1+2^l end if end do; t1 end proc;
  • Python
    a=1
    for n in range(2,66):
        print(a, end=",")
        a ^= a+n
    # Alex Ratushnyak, Apr 21 2012
    

Formula

a(n) = -n + Sum_{ k >= 1, k == n mod 2^k } 2^k. - N. J. A. Sloane and David Applegate, Mar 22 2005. E.g. a(5) = -5 + 2^1 + 2^5 = 29.
a(2^k + k) -a(k) = 2^(2^k + k) - 2^k, with k>= 1.
a(1)=1, for n>1, a(n) = a(n-1) XOR (a(n-1) + n), where XOR is the bitwise exclusive-or operator. - Alex Ratushnyak, Apr 21 2012
a(n) = A105027(A000225(n)). - Reinhard Zumkeller, Jul 21 2012

Extensions

More terms from Benoit Cloitre, Mar 20 2005
a(16)-a(22) from Robert G. Wilson v, Mar 21 2005
a(15)-a(29) from David Applegate, Mar 22 2005

A105033 Read binary numbers downwards to the right.

Original entry on oeis.org

0, 1, 0, 3, 2, 1, 4, 7, 6, 5, 0, 11, 10, 9, 12, 15, 14, 13, 8, 3, 18, 17, 20, 23, 22, 21, 16, 27, 26, 25, 28, 31, 30, 29, 24, 19, 2, 33, 36, 39, 38, 37, 32, 43, 42, 41, 44, 47, 46, 45, 40, 35, 50, 49, 52, 55, 54, 53, 48, 59, 58, 57, 60, 63, 62, 61, 56, 51, 34, 1, 68, 71, 70, 69, 64, 75
Offset: 0

Views

Author

N. J. A. Sloane, Apr 04 2005

Keywords

Comments

Equals A103530(n+2) - 1. - Philippe Deléham, Apr 06 2005
This sequence can also be produced as follows:
Using binary arithmetic, start with zero and repeatedly add 1 while deferring carries one iteration.
a(0) = 0, c(0) = 1
a(n) = a(n-1) XOR c(n-1)
c(n) = (a(n-1) AND c(n-1))*2+1
where c is the carries, XOR is bitwise exclusive-or, and AND is bitwise and.
This has the property that a(n) = n-c(n)+1. - Christopher Scussel, Jan 31 2025

Examples

			Start with the binary numbers:
  ......0
  ......1
  .....10
  .....11
  ....100
  ....101
  ....110
  ....111
  ...1000
  .......
and read downwards to the right, getting 0, 1, 0, 11, 10, 1, 100, 111, ...
		

Crossrefs

Analog of A102370. Cf. A105034, A105025.
Cf. triangular array in A103589.

Programs

  • Maple
    f:= proc (n) local t1, l; t1 := n; for l from 0 to n do if `mod`(n-l,2^(l+1)) = 0 and n >= 2^(l+1) then t1 := t1-2^(l+1) fi; od; t1; end proc;
  • Mathematica
    f[n_] := Block[{k = 0, s = 0}, While[2^(k + 1) < n + 1, If[ Mod[n, 2^(k + 1)] == k, s = s + 2^(k + 1)]; k++ ]; n - s]; Table[ f[n], {n, 0, 75}] (* Robert G. Wilson v, Apr 06 2005 *)

Formula

a(n) = n - Sum_{ k >= 0, 2^{k+1} <= n, n == k mod 2^(k+1) } 2^(k+1).
Structure: blocks of size 2^k taken from A105025, interspersed with terms a(n) itself! Thus a(2^k + k - 1 ) = a(k-1) for k >= 1.
From David Applegate, Apr 06 2005: (Start)
"a(n) = 2^k + a(n-2^k) if k >= 1 and 0 <= n - 2^k - k < 2^k, = a(n-2^k) if k >= 1 and n - 2^k - k = -1, or = 0 if n = 0 (and exactly one of the three conditions is true for any n >= 0).
"Equivalently, a(2^k + k + x) = 2^k + a(k+x) if 0 <= x < 2^k, = a(k+x) if x = -1 (for each n >= 0, there is a unique k, x such that 2^k + k + x = n, k >= 0, -1 <= x < 2^k). This recurrence follows immediately from the definition.
"The recurrence captures three observed facts about a: a(2^k + k - 1) = a(k-1); a consists of blocks of length 2^k of A105025 interspersed with terms of a; a(n) = n - Sum_{ k >= 0, 2^{k+1} <= n, n = k mod 2^(k+1) } 2^(k+1)." (End)
a(n) = sum_{k=0..n} A103589(n,k)*2^(n-k). - L. Edson Jeffery, Dec 01 2013

A103529 Values of A102370 which are >= a new power of 2.

Original entry on oeis.org

0, 3, 6, 15, 28, 61, 126, 251, 504, 1017, 2042, 4095, 8180, 16373, 32758, 65523, 131056, 262129, 524274, 1048567, 2097148, 4194285, 8388590, 16777195, 33554408, 67108841, 134217706, 268435439, 536870884, 1073741797, 2147483622
Offset: 1

Views

Author

N. J. A. Sloane and David Applegate, Mar 22 2005

Keywords

Examples

			The initial values of A102370 are 0*, 3*, 6*, 5, 4, 15*, 10, 9, 8, 11, 14, 13, 28*, 23, ... and the starred terms are those which exceed the next power of 2. Their indices (except for the zero term) are given by A000325.
		

Crossrefs

Programs

  • Python
    a=3
    print(0, end=',')
    for i in range(2,55):
        print(a, end= ',')
        a ^= a+i
    # Alex Ratushnyak, Apr 21 2012

Formula

a(n) = 2^(n-1) - (n-1) + Sum_{ k >= 1, k == n-1 mod 2^k } 2^k.
a(n+1) = 2^n + A102371(n) for n>=1. a(n) = 2^n - A103530(n). - Philippe Deléham, Mar 30 2005
a(0)=0, a(1)=3, for n>1, a(n)= a(n-1) XOR (a(n-1)+n), where XOR is the bitwise exclusive-or operator. - Alex Ratushnyak, Apr 21 2012
Showing 1-4 of 4 results.