Sequences Fibonacci style Ok, so I've had a go at this question and have yielded 36 pairs so far but there are actually 40 to be found so I am 4 short. The question is: A sequence of non-negative integers with nth term u(n) is defined by u(1) = a and u(2) = b, and u(n+2) = u(n+1) + u(n). How many pairs of non-negative integrers (a,b) are there such that all the following are true?
1) 21 is a term of the sequence
2) a not equal to 21
3) b not equal to 21
What I have done so far:
If 21 is the 3rd term of the sequence, i.e. a + b, we have 20 different combinations to make 21: 1 + 20, 2 + 19 ... 20 + 1
If 21 is the 4th term of the sequence i.e. a + 2b, we have 10 different combinations 1 + 2*10, 3 + 2*9 ... 19 + 2*1 (also a must be odd)
If 21 is the 5th term of the sequence i.e. 2a + 3b I found three combinations: 2*3 + 3*5, 6*2 + 3*3, 9*2 + 3*1
If 21 is the 6th term of the sequence i.e. 3a + 5b I found 1 combination: 3*2 + 5*3
If 21 is the 7th term of the sequence i.e. 5a + 8b I found 1 combination: 5*1 + 8*2
If 21 is the 8th term of the sequence i.e. 8a + 13b I found 1 combination 8*1 + 13*1 
21 cannot be the 9th term with these rules since we have already used a = 1 and b = 1 so it is impossible.
But yeah, this totals to 36 and there are 40 combinations. Any further help would be much appreciated :)
 A: You're missing:
a=0, b=1
a=1, b=0
a=0, b=7
a=7, a=0
A: Others have noted your mistake.
It's probably easier to count based on the second to last element of the sequence, which must be non-zero and less than 21. 
Let $u_{n}=21$. Then $0< u_{n-1}<21$. 
Example: If $u_{n-1}=12$, then $u_{n-2}=9, u_{n-3}=3,u_{n-4}=6,u_{n-5}=-9$. So we can start with $(a,b)=(6,3),(3,9),$ or $(9,12)$.
If $0<u_{n-1}<11$ then there is only one such sequence, giving $10$.
If $u_{n-1}>10$ then tracing back gives us $21,u_{n-1},21-u_{n-1},2u_{n-1}-21, 42-3u_n$. If $u_{n-1}>14$ then we have to stop at $2u_{n-1}-21$, so we get two options for each $u_{n-1}>14$, or an additional 14.
So you only need to deal with the cases $u_{n-1}\in\{11,12,13,14\}$.
When it is $11$, the priors can be $21,11,10,1,9$, or three possible starting points.
When it is $12$, the priors can be $21,12,9,3,6$, again three possible starting points.
If $u_{n-1}=13$, then $21,13,8,5,3,2,1,0$ give us $6$.
If $u_{n-1}=14$, then $21,14,7,7,0,7$ gives us $4$ possibles.
This gives us $40$.
An exact summation formula for general end value $M$ can be written. Let $F_n$ be the $n$th Fibonacci number with $F_0=0,F_1=1$. 
We won't exclude $a,b=M$ for now. We can subtract those later.
Then the number of sequences of length $k\geq 2$ starting from some $a,b\geq 0$ ending in in $M$ is the number of integers in the range between $M\frac{F_{k-2}}{F_{k-1}}$ and $M\frac{F_{k-1}}{F_{k}}$, inclusive.
Let $\alpha_k=\frac{F_{k-1}}{F_k}$.
Since the $\alpha_k$ alternate on either side of $\frac{-1+\sqrt{5}}{2}=\phi^{-1}$ we have to distinguish even and odd. For $k=2j$ we get $\alpha_{k-1}<\alpha_k$ and the number if integers between $\alpha_{k-1}$ and $\alpha_k$ is $\lfloor \alpha_{2j}M\rfloor-\lceil \alpha_{2j-1}M\lceil+1$
The number of integers between $\alpha$ and $\beta$, inclusive when $\alpha<\beta$ is $\lfloor \beta\rfloor -\lceil\alpha\rceil+1$.
We have that $\alpha_{2j-1}<\alpha_{2j}<\alpha_{2j-2}$, so combining terms $k=2j,2j-1$, we get the sum:
$$\sum_{j=1}^{\infty} \left(2\lfloor \alpha_{2j}M\rfloor -\lceil\alpha_{2j+1}M\rceil -\lceil\alpha_{2j-1}M\rceil +2\right)$$
This is a finite sum - we get about $\log_{\phi}(M)$ non-zero terms.
