A122750 Triangle T(n,k) = (-1)^(k+1) if n is odd, = (-1)^k if n and k are even, = 2*(-1)^k if n is even and k is odd, 0<=k<=n.
1, -1, 1, 1, -2, 1, -1, 1, -1, 1, 1, -2, 1, -2, 1, -1, 1, -1, 1, -1, 1, 1, -2, 1, -2, 1, -2, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -2, 1, -2, 1, -2, 1, -2, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -2, 1, -2, 1, -2, 1, -2, 1, -2, 1
Offset: 0
Examples
Triangle begins: 1 -1, 1 1, -2, 1 -1, 1, -1, 1 1, -2, 1, -2, 1 -1, 1, -1, 1, -1, 1 1, -2, 1, -2, 1, -2, 1
Programs
-
Maple
A122750 := proc(n,k) if type(n,'even') then if type(k,'even') then (-1)^k ; else 2*(-1)^k ; end if; else (-1)^(k+1) ; end if; end proc: # R. J. Mathar, May 12 2013
-
Mathematica
T[n_, k_] := If [Mod[n, 2] == 1, (-1)^(k + 1), (-1)^k*(1 + Mod[k, 2])]; a = Table[T[n, k], {n, 0, 10}, {k, 0, n}]; Flatten[a] (* For the unsigned version: *) t[n_, m_] = 1 + Mod[n - m, 2]*Mod[m, 2]; a = Table[t[n, m], {n, 0, 10}, {m, 0, n}]; Flatten[a] (* Roger L. Bagula, Sep 06 2008 *)
Comments