OFFSET
0,9
LINKS
Alois P. Heinz, Antidiagonals n = 0..200, flattened
Wikipedia, Balanced ternary
EXAMPLE
Square array A(n,k) begins:
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
-1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ...
3, -2, 3, 3, 3, 3, 3, 3, 3, 3, 3, ...
4, -1, -3, 4, 4, 4, 4, 4, 4, 4, 4, ...
2, 5, -2, -4, 5, 5, 5, 5, 5, 5, 5, ...
-3, 6, -1, -3, -5, 6, 6, 6, 6, 6, 6, ...
-2, 7, 7, -2, -4, -6, 7, 7, 7, 7, 7, ...
-4, 3, 8, -1, -3, -5, -7, 8, 8, 8, 8, ...
9, 4, 9, 9, -2, -4, -6, -8, 9, 9, 9, ...
10, 10, 10, 10, -1, -3, -5, -7, -9, 10, 10, ...
MAPLE
A:= proc(n, k) option remember; `if`(n=0, 0,
(b-> b*A(iquo(n, b), k)+mods(n, b))(2*k+1))
end:
seq(seq(A(n, 1+d-n), n=0..d), d=0..14);
MATHEMATICA
A[n_, k_] := A[n, k] = If[n == 0, 0, With[{b = 2k+1},
b*A[Quotient[n, b], k] + Mod[n, b, -Quotient[b-1, 2]]]];
Table[Table[A[n, 1+d-n], {n, 0, d}], {d, 0, 14}] // Flatten (* Jean-François Alcover, Feb 09 2021, after Alois P. Heinz *)
CROSSREFS
AUTHOR
Alois P. Heinz, Aug 26 2019
STATUS
approved