login
Triangle T(n,k) read by rows: If k divides n then k-1, otherwise -1.
5

%I #23 Sep 08 2022 08:45:52

%S 0,0,1,0,-1,2,0,1,-1,3,0,-1,-1,-1,4,0,1,2,-1,-1,5,0,-1,-1,-1,-1,-1,6,

%T 0,1,-1,3,-1,-1,-1,7,0,-1,2,-1,-1,-1,-1,-1,8,0,1,-1,-1,4,-1,-1,-1,-1,

%U 9,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,0,1,2,3,-1,5,-1,-1,-1,-1,-1,11

%N Triangle T(n,k) read by rows: If k divides n then k-1, otherwise -1.

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

%F T(n,k) = -A191904(n,k) for n >= k.

%F Sum_{k=1..n} T(n,k) = A001065(n). - _Jon E. Schoenfield_, Nov 29 2019

%e Table begins:

%e 0;

%e 0, 1;

%e 0, -1, 2;

%e 0, 1, -1, 3;

%e 0, -1, -1, -1, 4;

%e 0, 1, 2, -1, -1, 5;

%e 0, -1, -1, -1, -1, -1, 6;

%e 0, 1, -1, 3, -1, -1, -1, 7;

%e 0, -1, 2, -1, -1, -1, -1, -1, 8;

%e 0, 1, -1, -1, 4, -1, -1, -1, -1, 9;

%p seq(seq( `if`(mod(n,k)=0, k-1, -1) , k=1..n), n=1..15); # _G. C. Greubel_, Nov 27 2019

%t Table[If[Divisible[n,k],k-1,-1],{n,15},{k,n}]//Flatten (* _Harvey P. Dale_, May 20 2016 *)

%o (PARI) T(n,k)= if(Mod(n,k)==0, k-1, -1); \\ _G. C. Greubel_, Nov 27 2019

%o (Magma) [(n mod k) eq 0 select k-1 else -1: k in [1..n], n in [1..15]]; // _G. C. Greubel_, Nov 27 2019

%o (Sage)

%o def T(n, k):

%o if (mod(n,k)==0): return k-1

%o else: return -1

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

%o (GAP)

%o T:= function(n,k)

%o if (n mod k = 0) then return k-1;

%o else return -1;

%o fi; end;

%o Flat(List([1..15], n-> List([1..n], k-> T(n,k) ))); # _G. C. Greubel_, Nov 27 2019

%Y Cf. A001065 (row sums), A191904.

%K sign,tabl

%O 1,6

%A _Mats Granvik_, Apr 08 2010