Is there a unique polynomial function $f(x)$ of degree $\lt n$ such that $f(n) = a_n$ where $\{a_n\}$ is a sequence? Is it true that for every sequence $a$ of $n$ numbers there is exactly one polynomial function $f(x)$ of degree $\leq n$ such that all $f(1)=a_1,f(2)=a_2,\dots f(n)=a_{n}$? If so, is there an algorithm to, given the sequence, generate the coefficients of this function?
Intuitively, I feel like this is true, because:


*

*Given $a$ and $b$, you can find a polynomial function $f$ that has degree $1$ such that $f(0)=a$ and $f(1)=b$.

*By induction: given coefficients $a_1,a_2\dots a_n$, you can find a polynomial function of degree $n$ such that $f(x)$ yields a constant value for all $x$ in $\{1,2\dots n-1\}$.


Mostly, the reason I want to be able to find such a function is so when my math teacher says "find the function rule" and presents us with an obviously linear function I can give her some strange polynomial that just happens to give the correct answers for those values.

Trolling here is far easier than you're making it out to be. If all you're given is a finite set of points and your teacher asks simply for a function -- not necessarily polynomial -- that fits them, you can just set $f(x_i)=y_i$ for $(x_i,y_i)$ in your list and $f(x)=0$ otherwise.
