OFFSET
1,2
COMMENTS
Each element in the pyramid below the base is equal to the sum of the top left, top, and top right elements.
Each row has 2*n-(1+2*r) elements where r is the row number starting from 0.
The sum of elements in the first row is n^2.
The total number of elements in the pyramid is n^2.
FORMULA
Empirical g.f.: x/(1-3*x)^2 - 2*x^2/((1+x)^(1/2)*(1-3*x)^(3/2)). - Robert Israel, Dec 17 2022
a(n) = n*3^(n-1) - 2*A132894(n-1) (conjectured). - Bernard Schott, Dec 20 2022
EXAMPLE
For n = 3:
1 2 3 2 1
6 7 6
19
so a(3) = 19.
For n = 4:
1 2 3 4 3 2 1
6 9 10 9 6
25 28 25
78
so a(4) = 78.
MAPLE
f:= proc(n) local L, i;
L:= [seq(i, i=1..n), seq(n-i, i=1..n-1)];
for i from 1 to n-1 do
L:= L[1..-3] + L[2..-2] + L[3..-1]
od;
op(L)
end proc:
map(f, [$1..30]); # Robert Israel, Dec 17 2022
MATHEMATICA
f[n_] := Module[{L, i}, L = Range[n]~Join~Table[n-i, {i, 1, n-1}]; For[i = 1, i <= n-1, i++, L = L[[1;; -3]] + L[[2;; -2]] + L[[3;; -1]]]; L[[1]]];
f /@ Range[30] (* Jean-François Alcover, Jan 25 2023, after Robert Israel *)
PROG
(C)
unsigned long tri(int n, int k)
{
if (n == 0 && k == 0) return 1;
if(k < -n || k > n) return 0;
return tri(n - 1, k - 1) + tri(n - 1, k) + tri(n - 1, k + 1);
}
unsigned long a(int n)
{
unsigned long sum = 0;
sum += tri(n - 1, 0) * n;
for (int i = 1; i < n; i++)
{
sum += 2 * tri(n - 1, n - i) * i;
}
return sum;
}
CROSSREFS
KEYWORD
nonn
AUTHOR
Moosa Nasir, Dec 15 2022
STATUS
approved