Is there a pattern (or a name and expression for the pattern) of the intervals between all primes? With the recent interest in Mersenne primes, I got thinking whether there was any mathematical expression for the pattern of intervals (or sequence composed of interval lengths) between ordinary prime numbers. For example, for the first ten primes,

2 3 5 7 11 13 17 19 23 29

The sequence would be:

1 2 2 4 2 4 2 4 6

Has anyone in mathematics taken enough interest in these intervals to express them as the sequence of a formula, or even give the sequence (if it's random can't be expressed with a formula) a name?
 A: See the terminology used, prime gap, http://en.wikipedia.org/wiki/Prime_gap.
A: Some references and information are also listed in the 
The On-Line Encyclopedia of Integer Sequences.
A: This will tell you most of the prime after $\{2,3,5,7\}$ but it will also show some which are not prime e.g 121 is in there but it's not prime  (11 x 11) 
$$f(x) = 2x + 1$$
$$ g(x) = (f(x) \mod 3)(f(x) \mod 5)(f(x) \mod 7) $$
$$ \exists n( (g(n) != 0) \Rightarrow f(n) \in \mathbb P ) $$
A: If you really want to express it as a sequence formula, apart from the generic formulas based on the prime counting function and some conjectures regarding the calculation of the gaps that can be found, as explained in the answer by k1next, at OEIS, there was a recent question asking for a formula for primes that can be also applied to this question to get something closer to the prime gap function. It has not practical value, but it is a valid formulation. 
There is an example of a formula of the prime counting function based on Wilson's theorem, and the formula is true only if:

$\forall j\gt0:\displaystyle f(j)=\frac{\sin^2\left(\pi\frac{(j-1)!^2}{j}\right)}{\sin^2\left(\frac{\pi}{j}\right)}$ has value $1$ when $j$ is prime and $0$ in the rest of cases.

Thus we could construct a formula for primes like this:

$$\forall j\gt0:\displaystyle f(j)=\frac{\sin^2\left(\pi\frac{(j-1)!^2}{j}\right)}{\sin^2\left(\frac{\pi}{j}\right)} \cdot j$$

So if we run a loop it should provide the list of primes and $0$'s as follows:
$$(j\ge1)\ [1,2,3,4,5,6,7,8,9,10,11...] \to (j\ge1)\ [0,2,3,0,5,0,7,0,0,0,11...](*)$$
So if we want to obtain the gaps, we can define a conditional formula as follows:

$$\forall j \ge 3: g_{j} = \begin{cases} 0 & \text{if $f(j)=0$} \\ 
 \\ f(j)-f(i) & \text{if $f(j) \gt 0 , i\lt j, f(i) \gt 0 \land \not\exists k : f(i) \lt f(k) \lt f(j)$} \end{cases}$$

It should provide a list of prime gaps and $0$'s:
$$(*)(j\ge1)\ [0,2,3,0,5,0,7,0,0,0,11...] \to (j \ge 3)\ [1,0,2,0,2,0,0,0,4...]$$
