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.

User: Brian Reed

Brian Reed's wiki page.

Brian Reed has authored 2 sequences.

A198193 Replace 2^k in the binary representation of n with n+(k-L) where L = floor(log(n)/log(2)).

Original entry on oeis.org

0, 1, 2, 5, 4, 8, 11, 18, 8, 15, 18, 28, 23, 35, 39, 54, 16, 30, 33, 50, 38, 57, 61, 83, 47, 70, 74, 100, 81, 109, 114, 145, 32, 61, 64, 96, 69, 103, 107, 144, 78, 116, 120, 161, 127, 170, 175, 221, 95, 141, 145, 194, 152, 203, 208, 262, 165, 220, 225, 283
Offset: 0

Author

Brian Reed, Oct 26 2011

Keywords

Comments

That is, if n = 2^a + 2^b + 2^c + ... then a(n) = (n+(a-L)) + (n+(b-L)) + (n+(c-L)) + ...).

Examples

			a(4) = (4+(2-2)) = 4 because int(log(4)/log(2)) = 2 and 4 = 2^2.
a(6) = (6+(2-2)) + (6+(1-2)) = 11 because int(log(6)/log(2)) = 2 and 6 = 2^2 + 2^1.
		

Crossrefs

Programs

  • MATLAB
    % n is number of terms to be computed, b is the base. The examples all use b=2:
    function [V] = revAddition(n,b)
       for i = 0:n
          k = i;
          if (i > 0)
             l = floor(log(i)/log(b));
          end
          s = 0;
          while(k ~= 0)
             if ((i-l) >= 0)
                s = s + mod(k,b)*(i-l);
             end
             l = l - 1;
             k = (k - mod(k,b))/b;
          end
          V(i+1) = s;
       end
    end
    
  • Maple
    read("transforms") :
    A198193 := proc(n)
            (n-A000523(n))*wt(n)+A073642(n) ;
    end proc:
    seq(A198193(n),n=0..20) ; # R. J. Mathar, Nov 17 2011
  • Mathematica
    Table[b = Reverse[IntegerDigits[n, 2]]; L = Length[b] - 1; Sum[b[[k]] (n + k - 1 - L), {k, Length[b]}], {n, 0, 59}] (* T. D. Noe, Nov 01 2011 *)
  • Python
    def A198193(n): return sum((n-i)*int(j) for i,j in enumerate(bin(n)[2:])) # Chai Wah Wu, Mar 13 2021

Formula

Let L = A000523(n), then a(n) = (n-L)*A000120(n) + A073642(n).

A198192 Replace 2^k in the binary representation of n with n-k (i.e. if n = 2^a + 2^b + 2^c + ... then a(n) = (n-a) + (n-b) + (n-c) + ...).

Original entry on oeis.org

0, 1, 1, 5, 2, 8, 9, 18, 5, 15, 16, 29, 19, 34, 36, 54, 12, 30, 31, 52, 34, 57, 59, 85, 41, 68, 70, 100, 75, 107, 110, 145, 27, 61, 62, 99, 65, 104, 106, 148, 72, 115, 117, 163, 122, 170, 173, 224, 87, 138, 140, 194, 145, 201, 204, 263, 156, 216, 219, 282, 226
Offset: 0

Author

Brian Reed, Oct 21 2011

Keywords

Examples

			a(5) = (5-2) + (5-0) = 8 because 5 = 2^2 + 2^0.
a(7) = (7-2) + (7-1) + (7-0) = 18 because 7 = 2^2 + 2^1 + 2^0.
		

Crossrefs

Programs

  • MATLAB
    % n is number of terms to be computed:
    function [B] = predAddition(n)
       for i = 0:n
          k = i;
          c = 0;
          s = 0;
          while(k ~= 0)
             if ((i - c) >= 0)
                s = s + mod(k,2)*(i-c);
             end
             c = c + 1;
             k = (k - mod(k,2))/2;
          end
          B(i+1) = s;
       end
    end
  • Maple
    b:= (n, k)-> `if`(n=0, 0, k*(n mod 2)+b(floor(n/2), k-1)):
    a:= n-> b(n, n):
    seq(a(n), n=0..100);  # Alois P. Heinz, Oct 25 2011

Formula

a(n) = n*A000120(n) - A073642(n). - Franklin T. Adams-Watters, Oct 22 2011
a(n) = b(n,n) with b(0,k) = 0, b(n,k) = k*(n mod 2) + b(floor(n/2),k-1) for n>0. - Alois P. Heinz, Oct 25 2011