A015818 Number of solutions of +- 1 +- 2 +- ... +- (n-1) +- n = 0 in which the partial sums +- 1 +- ... +- k (1<=k<=n) are all distinct.
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, 4170, 5996, 0, 0, 23642, 36616, 0, 0, 140500, 217002, 0, 0, 852132, 1374692, 0, 0, 5411800, 8852230, 0, 0, 35764246, 56370054, 0, 0, 232969442, 376479130, 0, 0, 1555855594, 2534308444
Offset: 0
Keywords
Examples
For n=4 there are 2 solutions: +1-2-3+4=0 and -1+2+3-4=0.
Links
- Leroy Quet, Integers Arranged: Q & Puzzle
Crossrefs
a(n) <= A063865(n).
Programs
-
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););} a(n) = if ((!n) || ((n % 4) != 1) && ((n % 4) != 2), sum(i=0, 2^n-1, issol(i, n))); \\ Michel Marcus, May 22 2014
Extensions
a(36)-a(46) from Ray Chandler, Nov 29 2008
a(47)-a(58) from Sean A. Irvine, Dec 13 2018
Comments