OFFSET
1,1
LINKS
G. C. Greubel, Rows n = 1..50 of the triangle, flattened
FORMULA
T(n,k,p,q,j) = T(n-1,k,p,q,j) + T(n-1,k-1,p,q,j) + (p*j+q)*prime(j)*T(n-2,k-1,p, q,j) with T(2,k,p,q,j) = prime(j), T(3,2,p,q,j) = 2*prime(j)^2 - 4, T(4,2,p,q,j) = T(4,3,p,q,j) = prime(j)^2 - 2, T(n,1,p,q,j) = T(n,n,p,q,j) = 2 and (p,q,j) = (0,1,2).
Sum_{k=0..n} T(n,k,p,q,j) = 2*prime(j)^(n-1) for (p,q,j) = (0,1,2) = 2*A000244(n-1).
EXAMPLE
Triangle begins as:
2;
3, 3;
2, 14, 2;
2, 25, 25, 2;
2, 33, 92, 33, 2;
2, 41, 200, 200, 41, 2;
2, 49, 340, 676, 340, 49, 2;
2, 57, 512, 1616, 1616, 512, 57, 2;
2, 65, 716, 3148, 5260, 3148, 716, 65, 2;
2, 73, 952, 5400, 13256, 13256, 5400, 952, 73, 2;
MATHEMATICA
T[n_, k_, p_, q_, j_]:= T[n, k, p, q, j]= If[n==2, Prime[j], If[n==3 && k==2 || n==4 && 2<=k<=3, ((3-(-1)^n)/2)*Prime[j]^(n-1) -2^((3-(-1)^n)/2), If[k==1 || k==n, 2, T[n-1, k, p, q, j] + T[n-1, k-1, p, q, j] + (p*j+q)*Prime[j]*T[n-2, k-1, p, q, j] ]]];
Table[T[n, k, 0, 1, 2], {n, 12}, {k, n}]//Flatten (* modified by G. C. Greubel, Mar 03 2021 *)
PROG
(Sage)
@CachedFunction
def f(n, j): return ((3-(-1)^n)/2)*nth_prime(j)^(n-1) - 2^((3-(-1)^n)/2)
def T(n, k, p, q, j):
if (n==2): return nth_prime(j)
elif (n==3 and k==2 or n==4 and 2<=k<=3): return f(n, j)
elif (k==1 or k==n): return 2
else: return T(n-1, k, p, q, j) + T(n-1, k-1, p, q, j) + (p*j+q)*nth_prime(j)*T(n-2, k-1, p, q, j)
flatten([[T(n, k, 0, 1, 2) for k in (1..n)] for n in (1..12)]) # G. C. Greubel, Mar 03 2021
(Magma)
f:= func< n, j | Round(((3-(-1)^n)/2)*NthPrime(j)^(n-1) - 2^((3-(-1)^n)/2)) >;
function T(n, k, p, q, j)
if n eq 2 then return NthPrime(j);
elif (n eq 3 and k eq 2 or n eq 4 and k eq 2 or n eq 4 and k eq 3) then return f(n, j);
elif (k eq 1 or k eq n) then return 2;
else return T(n-1, k, p, q, j) + T(n-1, k-1, p, q, j) + (p*j+q)*NthPrime(j)*T(n-2, k-1, p, q, j);
end if; return T;
end function;
[T(n, k, 0, 1, 2): k in [1..n], n in [1..12]]; // G. C. Greubel, Mar 03 2021
CROSSREFS
KEYWORD
AUTHOR
Roger L. Bagula, Dec 28 2008
EXTENSIONS
Edited by G. C. Greubel, Mar 03 2021
STATUS
approved