Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How many sequences $a_1,a_2,...,a_8$ from zeros and ones ,and such that :

$$a_1\cdot a_2+a_2 \cdot a_3+\cdots + a_7\cdot a_8=5$$

share|cite|improve this question
Is this homework ? what did you try ? – Belgi Sep 19 '12 at 12:04
You can solve the problem by analyzing how many zeros there are in the sequence and in each case which are the possible cases. – digital-Ink Sep 19 '12 at 12:17
up vote 0 down vote accepted

I will use Haskell to brute-force this. Here's a GHCi session:

Prelude> let xs = [ (a1,a2,a3,a4,a5,a6,a7,a8) | a1 <- [0,1], a2 <- [0,1],
                                                a3 <- [0,1], a4 <- [0,1],
                                                a5 <- [0,1], a6 <- [0,1],
                                                a7 <- [0,1], a8 <- [0,1], 
                                                a1*a2 + a2*a3 + a3*a4 + a4*a5 + a5*a6 + a6*a7 + a7*a8 == 5]
Prelude> xs
Prelude> length xs

So, the answer would be: there are $9$ sequences.

share|cite|improve this answer
Hey, you missed a5*a6!!! These sequences listed all give 6. – Berci Sep 19 '12 at 12:34
@BerciPecsi: You're totally right. I noticed the error and fixed it before I saw your comment. – Rod Carvalho Sep 19 '12 at 12:37

Hint: note that this means that exactly $5$ of the pairs are of the form $1\cdot 1$

share|cite|improve this answer
Would the downvoter care to explain what is wrong with my hint ? – Belgi Sep 19 '12 at 13:54

if any of a3,a4,a5,or a6 are zero, then no other element can be zero, since they would make two terms 0. so these inner ones give rise to 4 assignments. however, a2 and a7 are such that they are present with terms a1 and a8 respectively, and these appear only once. so if a2 is 0, a1 may or may not be zero, and similarly, if a7 is 0, a8 may or may not be 0, so these give rise to four more assigments. finally, we have one assignment with a1 0 and a8 0, and the rest are all 1's, for a total of 9 assignments.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.