login
Number of solutions of +- 1 +- 2 +- ... +- (n-1) +- n = 0 in which the partial sums +- 1 +- ... +- k (1<=k<=n) are all distinct.
2

%I #20 Dec 13 2018 16:17:16

%S 1,0,0,2,2,0,0,2,2,0,0,10,14,0,0,36,40,0,0,134,258,0,0,702,1040,0,0,

%T 4170,5996,0,0,23642,36616,0,0,140500,217002,0,0,852132,1374692,0,0,

%U 5411800,8852230,0,0,35764246,56370054,0,0,232969442,376479130,0,0,1555855594,2534308444

%N Number of solutions of +- 1 +- 2 +- ... +- (n-1) +- n = 0 in which the partial sums +- 1 +- ... +- k (1<=k<=n) are all distinct.

%C If n==1 or 2 (mod 4) then a(n)=0.

%H Leroy Quet, <a href="http://groups.google.com/groups?selm=b4be2fdf.0211251643.65f368e6%40posting.google.com">Integers Arranged: Q & Puzzle</a>

%e For n=4 there are 2 solutions: +1-2-3+4=0 and -1+2+3-4=0.

%o (PARI) issol(i, n) = {b = binary(i); while(length(b) < n, b = concat(0, b)); if (! sum(k=1, n, if (b[k], k, -k)), vsp = []; lastnb = 0; for (j=1, n, vsp = Set(concat(vsp, sum(k=1, j, if (b[k], k, -k)))); if (#vsp == lastnb, return (0)); lastnb = #vsp;); return (1););}

%o a(n) = if ((!n) || ((n % 4) != 1) && ((n % 4) != 2), sum(i=0, 2^n-1, issol(i, n))); \\ _Michel Marcus_, May 22 2014

%Y a(n) <= A063865(n).

%K nonn

%O 0,4

%A _Leroy Quet_, _Christian G. Bower_ and _I. J. Kennedy_, Nov 26 2002

%E a(36)-a(46) from _Ray Chandler_, Nov 29 2008

%E a(47)-a(58) from _Sean A. Irvine_, Dec 13 2018