login
Triangle read by rows: T(n,k) = p(k)*T(n-1,k) + T(n-1,k-1) (1 <= k <= n), where p(k) denotes the k-th prime.
4

%I #12 Sep 08 2022 08:45:28

%S 1,2,1,4,5,1,8,19,10,1,16,65,69,17,1,32,211,410,188,28,1,64,665,2261,

%T 1726,496,41,1,128,2059,11970,14343,7182,1029,58,1,256,6305,61909,

%U 112371,93345,20559,2015,77,1,512,19171,315850,848506,1139166,360612,54814,3478,100,1

%N Triangle read by rows: T(n,k) = p(k)*T(n-1,k) + T(n-1,k-1) (1 <= k <= n), where p(k) denotes the k-th prime.

%H G. C. Greubel, <a href="/A124960/b124960.txt">Rows n = 1..100 of triangle, flattened</a>

%e Triangle starts:

%e 1;

%e 2, 1;

%e 4, 5, 1;

%e 8, 19, 10, 1;

%e 16, 65, 69, 17, 1;

%e 32, 211, 410, 188, 28, 1;

%p T:=proc(n,k): if n=1 and k=1 then 1 elif k<1 or k>n then 0 else ithprime(k)*T(n-1,k)+T(n-1,k-1) fi end: for n from 1 to 11 do seq(T(n,k),k=1..n) od; # yields sequence in triangular form

%t T[n_, k_]:= T[n, k]= If[n==1 && k==1 , 1, If[k<1 || k>n, 0, Prime[k]*T[n-1, k] + T[n-1, k-1] ]]; Table[T[n, k], {n,12}, {k, n}]//Flatten (* _G. C. Greubel_, Nov 19 2019 *)

%o (PARI) T(n,k) = if(n==1 && k==1, 1, if(k<1 || k>n, 0, prime(k)*T(n-1, k) + T(n-1, k-1) )); \\ _G. C. Greubel_, Nov 19 2019

%o (Magma)

%o function T(n,k)

%o if k lt 1 or k gt n then return 0;

%o elif n eq 1 and k eq 1 then return 1;

%o else return NthPrime(k)*T(n-1,k) + T(n-1,k-1);

%o end if;

%o return T;

%o end function;

%o [T(n,k): k in [1..n], n in [1..12]]; // _G. C. Greubel_, Nov 19 2019

%o (Sage)

%o @CachedFunction

%o def T(n,k):

%o if (k<1 or k>n): return 0

%o elif (n==1 and k==1): return 1

%o else: return nth_prime(k)*T(n-1, k) + T(n-1, k-1)

%o [[T(n,k) for k in (1..n)] for n in (1..12)] # _G. C. Greubel_, Nov 19 2019

%Y T(2n,n) gives A332967 (for n>0).

%K nonn,tabl

%O 1,2

%A _Gary W. Adamson_, Nov 13 2006

%E Edited by _N. J. A. Sloane_, Nov 29 2006