%I #21 Oct 23 2023 02:11:47
%S 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,
%T 49,37,30,21,27,9,10,10,64,50,42,31,64,28,10,11,11,81,65,56,43,125,65,
%U 30,11,12,12,100,82,72,57,216,126,68,31,12,13,13,121,101,90,73,343
%N Square array T(a,n) read by antidiagonals: replace 2^i with a^i in binary representation of n, where a,n >= 2.
%C Sums of distinct powers of a. Numbers having only {0,1} in a-ary representation.
%H John Tyler Rascoe, <a href="/A104257/b104257.txt">Antidiagonals n = 2..140, flattened</a>
%F T(a, n) = (1/(a-1))*Sum_{j>=1} floor((n+2^(j-1))/2^j) * ((a-2)*a^(j-1) + 1).
%F T(a, n) = (1/(a-1))*Sum_{j=1..n} ((a-2)*a^A007814(j) + 1).
%F G.f. of a-th row: (1/(1-x)) * Sum_{k>=0} a^k*x^2^k/(1+x^2^k).
%F Recurrence: T(a, 2n) = a*T(a, n), T(a, 2n+1) = a*T(a, n) + 1, T(a, 0) = 0.
%e Array begins:
%e 2, 3, 4, 5, 6, 7, 8, 9, ...
%e 3, 4, 9, 10, 12, 13, 27, 28, ...
%e 4, 5, 16, 17, 20, 21, 64, 65, ...
%e 5, 6, 25, 26, 30, 31, 125, 126, ...
%e 6, 7, 36, 37, 42, 43, 216, 217, ...
%e 7, 8, 49, 50, 56, 57, 343, 344, ...
%e 8, 9, 64, 65, 72, 73, 512, 513, ...
%e 9, 10, 81, 82, 90, 91, 729, 730, ...
%e ...
%t T[_, 0] = 0; T[2, n_] := n; T[a_, 2] := a;
%t T[a_, n_] := T[a, n] = If[EvenQ[n], a T[a, n/2], a T[a, (n-1)/2]+1];
%t Table[T[a-n+2, n], {a, 2, 13}, {n, 2, a}] // Flatten (* _Jean-François Alcover_, Feb 09 2021 *)
%o (Python)
%o 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)
%o 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
%o (PARI) T(a, n) = fromdigits(binary(n), a); \\ _Michel Marcus_, Aug 19 2022
%Y Rows include (essentially) A005836, A000695, A033042, A033043, A033044, A033045, A033046, A033047, A033048, A033049, A033050, A033051, A033052.
%Y Columns include A000290, A002522, A002378, A000578, A001093, A034262, A071568, A011379, A098547, A027444.
%Y Main diagonal is A104258.
%K nonn,tabl
%O 2,1
%A _Ralf Stephan_, Mar 05 2005