OFFSET
1,2
COMMENTS
T(n, k) is the sum of the terms of the k-th column of an n X n square matrix M formed by writing the numbers 1, ..., n^2 successively forward and backward along the rows in zig-zag pattern (proved). The n X n square matrix M is defined as M[i, j, n] = j + n*(i - 1) if i is odd and M[i, j, n] = n*i - j + 1 if i is even (see the examples below).
The rows of even indices of the triangle T are made of all the same repeating number.
LINKS
FORMULA
G.f.: x*(x*(5 - 7*y) + x^4*(1 - 2*y) - x^3*(- 3 + y) - 3*x^2*(- 1 + y) + y)/((-1 + x)^4*(1 + x)^2*(-1 + y)^2).
E.g.f.: (1/4)*exp(-x + y)*(1 - x - 2*y + exp(2*x)*(-1 + 3*x + 6*x^2 + 2*x^3 + 2*y)). - Stefano Spezia, Jan 10 2019
EXAMPLE
n\k| 1 2 3 4 5 6
---+------------------------
1 | 1
2 | 5 5
3 | 14 15 16
4 | 34 34 34 34
5 | 63 64 65 66 67
6 | 111 111 111 111 111 111
...
For n = 1 the matrix M is
1
with column sum 1.
For n = 2 the matrix M is
1, 2
4, 3
with column sums 5, 5.
For n = 3 the matrix M is
1, 2, 3
6, 5, 4
7, 8, 9
with column sums 14, 15, 16.
MAPLE
a:=(n, k)->(n^3+n)/2+(k-(n+1)/2)*modp(n, 2): seq(seq(a(n, k), k=1..n), n=1..11); # Muniru A Asiru, Aug 24 2018
MATHEMATICA
f[n_] := Table[SeriesCoefficient[(x*(x*(5 - 7*y) + x^4*(1 - 2*y) - x^3*(-3 + y) - 3*x^2*(-1 + y) + y))/((-1 + x)^4*(1 + x)^2*(-1 + y)^2), {x, 0, i}, {y, 0, j}], {i, n, n}, {j, 1, n}]; Flatten[Array[f, 11]]
T[i_, j_, n_] := If[OddQ@ i, j + n*(i - 1), n*i - j + 1]; f[n_] := Plus @@@ Transpose[ Table[T[i, j, n], {i, n}, {j, n}]]; Array[f, 11] // Flatten (* Robert G. Wilson v, Aug 01 2018 *)
f[n_] := Table[SeriesCoefficient[1/4 E^(-x + y) (1 - x - 2 y + E^(2 x) (-1 + 3 x + 6 x^2 + 2 x^3 + 2 y)), {x, 0, i}, {y, 0, j}]*i!*j!, {i, n, n}, {j, 1, n}]; Flatten[Array[f, 11]] (* Stefano Spezia, Jan 10 2019 *)
PROG
(R) # by formula
for (n in 1:11){
t <- c(n, "")
for(j in 1:n){
t <- c(t, (n^3+n)/2+(j-(n+1)/2)*(n%%2), "")
}
cat(t, "\n")
} # yields sequence in triangular form
(MATLAB and FreeMat)
for(i=1:11);
for(j=1:i);
t=(i^3 + i)/2 + (j - (i + 1)/2)*mod(i, 2);
fprintf('%0.f\t', t);
end
fprintf('\n');
end % yields sequence in triangular form
(GAP)
A317617 := function(n)
local i, j, t;
for i in [1 .. n] do
for j in [1 .. i] do
t := (i^3 + i)/2 + (j - (i + 1)/2)*(i mod 2);
Print(t, "\t");
od;
Print("\n");
od;
end;
A317617(11); # yields sequence in triangular form
(Maxima) sjoin(v, j) := apply(sconcat, rest(join(makelist(j, length(v)), v)))$ display_triangle(n) := for i from 1 thru n do disp(sjoin(makelist((i^3+i)/2+(j-(i+1)/2)*mod(i, 2), j, 1, i), " ")); display_triangle(10);
(Magma) [[(n^3 + n)/2 + (k - (n + 1)/2)*(n mod 2): k in [1..n]]: n in [1..11]];
(PARI) M(i, j, n) = if (i % 2, j + n*(i-1), n*i - j + 1);
T(n, k) = sum(i=1, n, M(i, k, n));
tabl(nn) = for(n=1, nn, for(k=1, n, print1(T(n, k), ", ")); print); \\ Michel Marcus, Aug 09 2018
(GAP) Flat(List([1..11], n->List([1..n], k->(n^3+n)/2+(k-(n+1)/2)*(n mod 2)))); # Muniru A Asiru, Aug 24 2018
CROSSREFS
KEYWORD
nonn,tabl
AUTHOR
Stefano Spezia, Aug 01 2018
STATUS
approved