# [seqfan] Re: Sum +-j +-(j+1) +-(j+2) ... +-i equals zero.

Ron Hardin rhhardin at att.net
Mon Mar 22 12:16:04 CET 2010

```Thanks, the following (awk) formula for tab(i,j) seems to work for rows 1..79 so far

if(int((i+1)/2)%2!=int(j/2)%2)ans=1;
else if((i-j)%2==0) {
n=(i-j)/2;
if(j>n^2)ans=1;
else ans=0;
}
else ans=0;

[int() is floor, % is modulo]

rhhardin at mindspring.com
rhhardin at att.net (either)

----- Original Message ----
> From: "franktaw at netscape.net" <franktaw at netscape.net>
> To: seqfan at list.seqfan.eu
> Sent: Sun, March 21, 2010 11:03:25 PM
> Subject: [seqfan] Re: Sum +-j +-(j+1) +-(j+2) ... +-i equals zero.
>
> I think you would get a better idea of what is happening if you were to
show
> a table of the minimum possible non-negative value of the sum,
instead of
> just zeros and ones.

The blocks of 2x2 zeros and ones reflect parity: the
> sum has the same
parity regardless of what signs are used, so when that
> parity is odd,
there can be no solution.

The stuff happening near the
> diagonal reflects the cases where it the
individual numbers are too big for
> the variation between numbers to
offset them. Cases where j-i is even have
> an odd number of terms, and
you will see increasing minimums on such
> diagonals. Where i-j+1 == 2
(mod 4), the parity will always be wrong.
> When i-j+1 == 0 (mod 4),
there is always a solution: +j-(j+1)-(j+2)+(j+3)
>
+(j+4)-(j+5)-(j+6)+(j+7) + ....

In order to get a solution with an
> odd number of terms 2n+1 (so i = j +
2n), you need the first n+1 terms to
> sum to at least the sum of the
last n terms: j(n+1)+n(n+1)/2 >= jn
> +n(3n+1)/2, which reduces to j >=
n^2.

I think these two
> considerations cover every case, although I haven't
spent the time to fully
> work out the proof.

Franklin T. Adams-Watters

-----Original
> Message-----
From: Ron Hardin <
> href="mailto:rhhardin at att.net">rhhardin at att.net>

When can the sum
> of plus or minus consecutive integers be zero?

I get a weird table, entry
> i,,j zero iff the sum of +-j +-(j+1) +-(j+2)
... +-i
equals zero for some
> choice of signs.

01  1
02  1 1
03  0 1 1
04
> 0 1 1 1
05  1 0 1 1 1
06  1 0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 0 1 1 1 0 1 1
> 1
32  0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 0 1 1 1 0 1 1
> 1
33  1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 1 1 0 1 1
> 1
34  1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 0 1 1 1 0 1 1
> 1
35  0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 1 1 0 1
> 1
1
36  0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 0 1
> 1 1 0 1
1 1
37  1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0
> 1 1 1 0 1 1 1 0
1 1 1
38  1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
> 0 0 1 1 0 0 1 1 1 0 1 1 1
0 1 1 1
39  0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
> 0 0 1 1 0 0 1 1 0 0 1 1 0 1 1 1 0 1 1
1 0 1 1
1
40  0 1 1 0 0 1 1
> 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 0 1
1 1 0 1
1
> 1

A formula would be nice (that was the original plan - I don't have to
>
check for
zero if the sum can't be zero.

The weirdness is the slow
> replacement of 2x2 zero blocks by a single
diagonal
zero,
> encroaching
leftwards from the main
> diagonal.

_______________________________________________

Seqfan
> Mailing list -
> >http://list.seqfan.eu/

```

More information about the SeqFan mailing list