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.

A104257 Square array T(a,n) read by antidiagonals: replace 2^i with a^i in binary representation of n, where a,n >= 2.

Original entry on oeis.org

2, 3, 3, 4, 4, 4, 5, 5, 9, 5, 6, 6, 16, 10, 6, 7, 7, 25, 17, 12, 7, 8, 8, 36, 26, 20, 13, 8, 9, 9, 49, 37, 30, 21, 27, 9, 10, 10, 64, 50, 42, 31, 64, 28, 10, 11, 11, 81, 65, 56, 43, 125, 65, 30, 11, 12, 12, 100, 82, 72, 57, 216, 126, 68, 31, 12, 13, 13, 121, 101, 90, 73, 343
Offset: 2

Views

Author

Ralf Stephan, Mar 05 2005

Keywords

Comments

Sums of distinct powers of a. Numbers having only {0,1} in a-ary representation.

Examples

			Array begins:
  2,  3,  4,  5,  6,  7,   8,   9, ...
  3,  4,  9, 10, 12, 13,  27,  28, ...
  4,  5, 16, 17, 20, 21,  64,  65, ...
  5,  6, 25, 26, 30, 31, 125, 126, ...
  6,  7, 36, 37, 42, 43, 216, 217, ...
  7,  8, 49, 50, 56, 57, 343, 344, ...
  8,  9, 64, 65, 72, 73, 512, 513, ...
  9, 10, 81, 82, 90, 91, 729, 730, ...
  ...
		

Crossrefs

Programs

  • Mathematica
    T[, 0] = 0; T[2, n] := n; T[a_, 2] := a;
    T[a_, n_] := T[a, n] = If[EvenQ[n], a T[a, n/2], a T[a, (n-1)/2]+1];
    Table[T[a-n+2, n], {a, 2, 13}, {n, 2, a}] // Flatten (* Jean-François Alcover, Feb 09 2021 *)
  • PARI
    T(a, n) = fromdigits(binary(n), a); \\ Michel Marcus, Aug 19 2022
  • Python
    def T(a, n): return n if n < 2 else (max(a, n) if min(a, n) == 2 else a*T(a, n//2) + n%2)
    print([T(a-n+2, n) for a in range(2, 14) for n in range(2, a+1)]) # Michael S. Branicky, Aug 02 2022
    

Formula

T(a, n) = (1/(a-1))*Sum_{j>=1} floor((n+2^(j-1))/2^j) * ((a-2)*a^(j-1) + 1).
T(a, n) = (1/(a-1))*Sum_{j=1..n} ((a-2)*a^A007814(j) + 1).
G.f. of a-th row: (1/(1-x)) * Sum_{k>=0} a^k*x^2^k/(1+x^2^k).
Recurrence: T(a, 2n) = a*T(a, n), T(a, 2n+1) = a*T(a, n) + 1, T(a, 0) = 0.