Hopefully this isn't too far above your head. This is the most elegant way I know of to solve this, and it generalizes immediately to fitting of arbitrary degree and (with some knowledge of pseudoinverses) to best fit polynomials for overdetermined systems (as well as a fairly wide class of non-polynomial fits).
Take the Vandermonde matrix: $A= \left( \begin{array}{ccc} 1 & 1 & 1 & 1 & 1 & 1 \\ 1 & 2 & 2^2 & 2^3 & 2^4 & 2^5 \\ 1 & 3 & 3^2 & 3^3 & 3^4 & 3^5 \\ 1 & 4 & 4^2 & 4^3 & 4^4 & 4^5 \\ 1 & 5 & 5^2 & 5^3 & 5^4 & 5^5 \\ 1 & 6 & 6^2 & 6^3 & 6^4 & 6^5 \\ \end{array} \right) $
and the column vector $b=\left( \begin{array}{ccc} f(1) & f(2) & f(3) & f(4) & f(5) & f(6)\\ \end{array} \right)^{T} $, where $T$ denotes the transpose and $f$ is the undetermined polynomial of degree 5 (or less).
The equation you want to solve is the linear equation $A y = b$ for a column vector $y$. The reason for this is that if you take an arbitrary row of the matrix and multiply it by $y$, what you get is $f(n) = a_0 +a_1 n + a_2 n^2 + a_3 n^3 + a_4 n^4 + a_5 n^5$, where $y=\left( \begin{array}{ccc} a_0 & a_1 & a_2 & a_3 & a_4 & a_5\\ \end{array} \right)^{T}$ and $n \in \{1,2,3,4,5,6\}$.
The solution is, of course, $y = A^{-1}b$. The general formula for the inverse of a Vandermonde matrix is known, and in this case the inverse is:
$A^{-1} = \frac{1}{120} \left( \begin{array}{ccc} 720 & -1800 & 2400 & -1800 & 720 & -120 \\ -1044 & 3510 & -5080 & 3960 & -1620 & 274 \\ 580 & -2305 & 3720 & -3070 & 1300 & -225 \\ -155 & 685 & -1210 & 1070 & -475 & 85 \\ 20 & -95 & 180 & -170 & 80 & -15 \\ -1 & 5 & -10 & 10 & -5 & 1 \\ \end{array} \right) $
(Please check this if you intend to use it as I could have easily made a typo)
Now with simple multiplication you can find $a_0, \ldots, a_5$, and the polynomial you want is $f(x) = a_0 + a_1 x + a_2 x^2 + \cdots + a_5 x^5$.
EDIT I feel it necessary to point out that this isn't a terribly good method for interpolation in most real-world situations, and it's absolutely terrible for extrapolation. See, for example, Runge's Phenomenon. If you are going to use this method for interpolation, you should use the lowest degree polynomials that accurately represent the data. There are methods that don't have the same issues (though of course no method is perfect); you should ask a separate question about these if you are interested.