How do I find the first seed when given the values of the second and third seeds to determine the sequence that must contain the number 2017? A tribonacci sequence is a sequence of numbers such that each term from the fourth onwards is the sum of the previous three. If a tribonacci sequence has 20 as its second seed and 17 as its third seed, find all positive integers that can be its first seed so that 2017 appears some where as a term in the sequence. Is there a rule that I could use to solve this rather then trial and error?
 A: It's not hard to convince yourself that if the first term of the sequence is an indeterminate $t$, the general term can be written uniquely in the form 
$$ a_n = \alpha_n t + \beta_n$$
for some integers $\alpha_n,\beta_n>0$ that don't depend on $t$. Now naturally $\alpha,\beta$ will be given by recurrence relations: we have 
$$ \alpha_{n+3}t + \beta_{n+3} = (\alpha_{n+2}+\alpha_{n+1}+\alpha_n)t + (\beta_{n+2}+\beta_{n+1}+\beta_n)$$
which means that the two sequences $\alpha,\beta$ are Tribonacci themselves; moreover, $\alpha_1=1,\alpha_2=0,\alpha_3=0$ and $\beta_1=0, \beta_2=20,\beta_3=17$. 
However, beyond that point it seems hard not to resort to brute-force (i.e., compute the first several terms of the sequences $\alpha$ and $\beta$ and try to match them to 2017 with some $t$ - there shouldn't be too many terms because $\beta$ is growing fairly fast.
A: You can limit the search by making the first term $1$ and observing what term is the first one greater than $2017$.  As increasing the first term will only increase all the others, that gives a bound.  You can certainly write things like $a_5=a_4+a_3+a_2=2a_3+2a_2+a_1$, set $a_5=2017$, and solve for $a_1.$  As you go to later terms there will be a coefficient on $a_1$ so the division may not produce an integer.  As you go later in the series it will get more tedious to write the expression in terms of $a_3, a_2, a_1$, but you can do it.  I found it easier just to make an Excel column and use Goal Seek.  As it to set $a_8$ to $2017$ by changing $a_1$ and see if it comes out an integer.
