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.

A072170 Square array T(n,k) (n >= 0, k >= 2) read by antidiagonals, where T(n,k) is the number of ways of writing n as Sum_{i>=0} c_i 2^i, c_i in {0,1,...,k-1}.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 3, 2, 2, 1, 1, 1, 2, 3, 2, 2, 1, 1, 1, 3, 3, 4, 2, 2, 1, 1, 1, 1, 4, 3, 4, 2, 2, 1, 1, 1, 4, 4, 5, 4, 4, 2, 2, 1, 1, 1, 3, 5, 4, 5, 4, 4, 2, 2, 1, 1, 1, 5, 5, 8, 5, 6, 4, 4, 2, 2, 1, 1, 1, 2, 6, 6, 8, 5, 6, 4, 4, 2, 2, 1, 1, 1, 5, 6, 9, 8, 9, 6, 6, 4, 4, 2, 2, 1, 1
Offset: 0

Views

Author

N. J. A. Sloane, Jun 29 2002

Keywords

Comments

k-th column is k-th binary partition function.
The sequence data corresponds (via the table link) to the transpose of the array shown in example and given by the definition. - M. F. Hasler, Feb 14 2019

Examples

			Array begins: (rows n >= 0, columns k >= 2)
1 1 1 1 1 1 1 1 ...
1 1 1 1 1 1 1 1 ...
1 2 2 2 2 2 2 2 ...
1 1 2 2 2 2 2 2 ...
1 3 3 4 4 4 4 4 ...
1 2 3 3 4 4 4 4 ...
1 3 4 5 5 6 6 6 ...
		

Crossrefs

k=3 column is A002487, k=4 is A008619 (positive integers repeated), k = 5, 6, 7 are A007728, A007729, A007730, limiting (infinity) column is A000123 doubled up.

Programs

  • Maple
    b:= proc(n, i, k) option remember;
          `if`(n=0, 1, `if`(i<0, 0, add(`if`(n-j*2^i<0, 0,
             b(n-j*2^i, i-1, k)), j=0..k-1)))
        end:
    T:= (n, k)-> b(n, ilog2(n), k):
    seq(seq(T(d+2-k, k), k=2..d+2), d=0..14); # Alois P. Heinz, Jun 21 2012
  • Mathematica
    b[n_, i_, k_] := b[n, i, k] = If[n == 0, 1, If[i < 0, 0, Sum[If[n-j*2^i < 0, 0, b[n-j*2^i, i-1, k]], {j, 0, k-1}]]];
    t[n_, k_] := b[n, Length[IntegerDigits[n, 2]] - 1, k];
    Table[Table[t[d+2-k, k], {k, 2, d+2}], {d, 0, 14}] // Flatten (* Jean-François Alcover, Jan 14 2014, translated from Alois P. Heinz's Maple code *)
  • PARI
    M72170=[[]]; A072170(n,k,i=logint(n+!n,2),r=1)={if( !i, k>n, r&&(k<5||k>=n),if(k>4, A000123(n\2)-(k==n), k<3, 1, k<4, A002487(n), n\2+1), M72170[r=setsearch(M72170,[n,k,i,""],1)-1][^-1]==[n,k,i], M72170[r][4], M72170=setunion(M72170,[[n,k,i,r=sum(j=0,min(k-1,n>>i),A072170(n-j*2^i,k,i-1,0))]]);r)} \\ Code for k<5 (using A002487 for k=3) and k>=n (using A000123) is optional but makes it about 3x faster. - M. F. Hasler, Feb 14 2019

Formula

T(n,k) = T(n,n+1) = T(n,n)+1 = A000123(floor(n/2)) for all k >= n+1. - M. F. Hasler, Feb 14 2019