login
T(n,k) = 1 if the sum of +-k..+-n with arbitrary signs never equals zero, = 0 otherwise (lower triangle)
1

%I #17 Sep 24 2023 10:20:16

%S 1,1,1,0,1,1,0,1,1,1,1,0,1,1,1,1,0,0,1,1,1,0,1,1,0,1,1,1,0,1,1,0,0,1,

%T 1,1,1,0,0,1,1,0,1,1,1,1,0,0,1,1,1,0,1,1,1,0,1,1,0,0,1,1,0,1,1,1,0,1,

%U 1,0,0,1,1,1,0,1,1,1,1,0,0,1,1,0,0,1,1,0,1,1,1,1,0,0,1,1,0,0,1,1,1,0,1,1,1,0,1,1

%N T(n,k) = 1 if the sum of +-k..+-n with arbitrary signs never equals zero, = 0 otherwise (lower triangle)

%H R. H. Hardin, <a href="/A174600/b174600.txt">Table of n, a(n) for n=1..4950</a>

%e Triangle begins

%e 1;

%e 1, 1;

%e 0, 1, 1;

%e 0, 1, 1, 1;

%e 1, 0, 1, 1, 1;

%e 1, 0, 0, 1, 1, 1;

%e 0, 1, 1, 0, 1, 1, 1;

%e 0, 1, 1, 0, 0, 1, 1, 1;

%e 1, 0, 0, 1, 1, 0, 1, 1, 1;

%e 1, 0, 0, 1, 1, 1, 0, 1, 1, 1; ...

%t t[n_, k_] := If[Mod[Floor[(n+1)/2], 2] != Mod[Floor[k/2], 2], 1, If[Mod[n-k, 2] == 0, If[k > ((n-k)/2)^2, 1, 0], 0]]; Flatten[Table[t[n, k], {n, 1, 15}, {k, 1, n}]][[;; 108]] (* _Jean-François Alcover_, Jul 11 2011, after awk program *)

%o (AWK)

%o { for(n=1; n<10; n++)

%o for(k=1; k<=n; k++)

%o print ++i, T(n,k);

%o }

%o function T(n,k) {

%o if ( int((n+1)/2)%2 != int(k/2)%2 ) return 1;

%o else if ( (n-k)%2 == 0 ) {

%o if ( k > ((n-k)/2)^2 ) return 1;

%o else return 0;

%o }

%o else return 0;

%o }

%o (PARI)

%o T(n,k)=

%o {

%o if ( ((n+1)\2)%2 != (k\2)%2,

%o return(1);

%o , /* else */

%o if ( (n-k)%2 == 0,

%o if ( k > ((n-k)/2)^2, return(1), return(0) );

%o , /* else */

%o return(0);

%o );

%o );

%o }

%o { for(n=1, 10, /* show triangle */

%o for(k=1,n,

%o print1(T(n,k),", ");

%o );

%o print();

%o ); }

%Y Related to A063865.

%K nonn,tabl

%O 1,1

%A _R. H. Hardin_ Mar 23 2010, with formula and reference from Franklin T. Adams-Watters and _Olivier Gérard_, on the Sequence Fans Mailing list.