Frequently in mathematics the best way to determine the value of a sequence at a particular index is to compute its value at every index, even though the latter seems on the surface like a harder problem.  

Here is one of my favorite examples of this phenomenon.  Suppose you want to know how many vectors of a particular norm there are in some lattice $L$.  On the surface, this seems like a hard problem - it involves figuring out how many times some quadratic form takes some value.  One can solve this problem by solving the harder problem of determining the answer for **every** possible norm by writing down the theta function
$$\Theta_L(\tau) = \sum_{v \in L} e^{-\pi \tau \left< v, v \right>}.$$

If $L$ satisfies certain technical properties, $\Theta_L$ is a modular form with respect to some congruence subgroup, and modular forms live in finite-dimensional vector spaces; moreover, a lot is known about how to write down modular forms.  For example, the theta function of the $E_8$ lattice is a modular form of weight $4$ and level $1$.  The space of such forms is one-dimensional - in fact, it's spanned by an Eisenstein series - and it then follows that
$$\Theta_{E_8}(\tau) = 1 + 240 \sum_{n \ge 1} \sigma_3(n) q^n$$

where $q = e^{2\pi i \tau}$.  Similar considerations lead to the well-known formulas for the number of ways to represent an integer as the sum of two or four squares.