Given the first $n$ terms of a sequence, can we find a function which would generate any infinite sequence we like that has the same first $n$ terms? I was thinking about questions you sometimes see of the form

Find the next $3$ terms of the sequence $$2, 3, 5, 7, ...$$

Presumably this example would want us to find the next three prime numbers, but it occurred to me that this could also be the sequence of roots, in ascending order, of the polynomial $$(x-2)(x-3)(x-5)(x-7)...$$ in which case the answer is any three numbers I darn well feel like as long as they are greater than 7 and in ascending order.
I am wondering if there are more general ways to do this where, given $n$ terms of a sequence, I can find a function $f:\mathbb{N}\rightarrow \mathbb{N}$ such that $f(i)$ for $i\leq n$ is the $i$th term of the given sequence, and for $i>n$ it's whatever I want. Polynomial roots don't work because there are finitely many of them, and I would like my sequence to be infinite. I imagine that maybe we would have to incorporate trigonometric functions. 
I tried searching around on the internet but I didn't know what to search for. Anyone know if this is a thing?
 A: Suppose it is given $f(i)=b_i$ for $1\leq i\leq n$. Now let us assume the function is given by a polynomial namely, $f(i)=a_1+a_2i+a_3i^2+\cdots+a_ni^{n-1}$ for all $i$. Then equating $f(i)=b_i$ for $i=1,\ldots ,n$ one can have a system of $n$ linear equation, which can be solved to get the values of $a_i$. Hence we know a function $f$ which assumes the given values at first $n$ points.
A: Since you're asking about functions that take values in the natural numbers, the answer is "yes" and you can even take your function to be analytic outside of maybe a finite number of points.
Let $(a_n)$ be a sequence of natural numbers. If $a_n \to +\infty$, then there exists a holomorphic function $f$ on $\mathbb C$ such that $f(n) = a_n$. This is a theorem of Mittag-Leffler and uses somewhat sophisticated machinery of complex analysis in one variable, but nothing that isn't within reach of undergraduates.
If $a_n$ does not tend to infinity, there should still exist a meromorphic function $f$ on $\mathbb C$ that interpolates the sequence, but the proof might be a little harder.
