# About some finite sequences of integers

The following sequence of p = 7 terms: 5 ; -3 ; 1 ; -4 ; 6 ; -4 ; 1 has a positive sum, and each sum of q = 4 consecutive terms is negative. Does anybody know the general conditions on p and q to obtain that kind of property?

-
You mean non-positive? -3+1-4+6 = 0. – M.B. Jun 13 '12 at 15:46
Thanks you, it is a mistake, I prefer negative : 5;-3;1;-4;5;-4;1 – Boudine Jun 13 '12 at 16:59
check this link – bleh Jun 14 '12 at 6:04

This can be done if and only if $q$ doesn't divide $p$.

If $q$ doesn't divide $p$, $p=qn+r$, with $r >0$. Then the sequence

$q-1, -1, -1, -1, .., -1$ wher e there are $r$ terms, followed by a series of $n$ sequences of the form

$-1, -1, ..., q-1$, with $q$ terms works.

The exact sequence is $a_1, a_2,... a_n$ where

$a_1=q-1, a_{r+qk}=q-1 \forall 1 \leq k \leq n-1$ and $a_l=-1$ otherwide.

If $q$ divides $p$, it is trivial to show that such sequence cannot exist.

if you need the sum to be strictly negative, the problem becomes more complicated...

-
Thank you. My purpose is to get the sum strictly negative. Folowing your method, I mean, with p = nq+r, to take n blocks A of q terms, like A = {(n+2), 0,..0,-1,-(n+2)}. So, the sum of these n blocks is (-n). The sum of the last r terms of the sequence must be (n+1).This part will be {0,0,...,0,(n+1). – Boudine Jun 13 '12 at 18:51