TITLE: Consecutive birthdays probability
QUESTION [20 upvotes]: Let $n$ be a number of people. At least two of them may be born on the same day of the year with probability: $$1-\prod_{i=0}^{n-1} \frac{365-i}{365}$$
But what is the probability that at least two of them are born on two consecutive days of the year (considering December 31st and January 1st also consecutive)? It seems a good approximation is: $$1-\prod_{i=0}^{n-1} \frac{365-2 \times i}{365}$$
However, simulating pseudo-random integers with Python, the 99%-confidence intervals may be slightly different. So do you have any closed formula?

Results of the simulation with Python. Here are 99%-confidence intervals below:
Number of people:  1    Lower bound: 0.0        Upper bound: 0.0
Number of people:  2    Lower bound: 0.00528    Upper bound: 0.00567
Number of people:  3    Lower bound: 0.01591    Upper bound: 0.01657
Number of people:  4    Lower bound: 0.03185    Upper bound: 0.03277
Number of people:  5    Lower bound: 0.0528     Upper bound: 0.05397
Number of people:  6    Lower bound: 0.07819    Upper bound: 0.07959
Number of people:  7    Lower bound: 0.10844    Upper bound: 0.11006
Number of people:  8    Lower bound: 0.14183    Upper bound: 0.14364
Number of people:  9    Lower bound: 0.17887    Upper bound: 0.18086
Number of people: 10    Lower bound: 0.21816    Upper bound: 0.2203
Number of people: 11    Lower bound: 0.25956    Upper bound: 0.26183
Number of people: 12    Lower bound: 0.30306    Upper bound: 0.30544
Number of people: 13    Lower bound: 0.34678    Upper bound: 0.34925
Number of people: 14    Lower bound: 0.39144    Upper bound: 0.39397
Number of people: 15    Lower bound: 0.43633    Upper bound: 0.4389
Number of people: 16    Lower bound: 0.48072    Upper bound: 0.48331
Number of people: 17    Lower bound: 0.52476    Upper bound: 0.52734


I give here some results with a tweaked approximation formula, using Wolfram Alpha:
$$\left( 1 - \frac{n-1}{2 \times 365 + n-1} \right) \times \left( 1-\prod_{i=0}^{n-1} \frac{365-2 \times i}{365} \right)$$
However, this is just a tweak, ans is clearly wrong for $n=33$ since:
Number of people: 33    My guess: 0.91407
Number of people: 33    Lower bound: 0.94328    Upper bound: 0.94447


Thanks to Jacopo Notarstefano, leonbloy, and Moron, here is the (correct) formula:
$$ 1-\sum_{k=1}^{n}\frac{1}{365^{n-k}k}\left(\prod_{i=1}^{k-1}\frac{365-\left(k+i\right)}{365\times i}\right)\sum_{j=0}^{k-1}\left(-1\right)^{j}C_{k}^{j}\left(k-j\right)^{n} $$
And here are the results of the computations using this formula with Python:
Number of people:  1    Probability: 0.0
Number of people:  2    Probability: 0.005479452
Number of people:  3    Probability: 0.016348283
Number of people:  4    Probability: 0.032428609
Number of people:  5    Probability: 0.053459591
Number of people:  6    Probability: 0.079104502
Number of people:  7    Probability: 0.108959718
Number of people:  8    Probability: 0.14256532
Number of people:  9    Probability: 0.179416899
Number of people: 10    Probability: 0.218978144
Number of people: 11    Probability: 0.260693782
Number of people: 12    Probability: 0.304002428
Number of people: 13    Probability: 0.34834893
Number of people: 14    Probability: 0.393195856
Number of people: 15    Probability: 0.438033789
Number of people: 16    Probability: 0.482390182
Number of people: 17    Probability: 0.525836596
Number of people: 18    Probability: 0.567994209
Number of people: 19    Probability: 0.608537602
Number of people: 20    Probability: 0.647196551
Number of people: 21    Probability: 0.683756966
Number of people: 22    Probability: 0.718059191
Number of people: 23    Probability: 0.749995532
Number of people: 24    Probability: 0.779509664
Number of people: 25    Probability: 0.806569056
Number of people: 26    Probability: 0.831211564
Number of people: 27    Probability: 0.853561895
Number of people: 28    Probability: 0.873571839
Number of people: 29    Probability: 0.892014392
Number of people: 30    Probability: 0.906106867
Number of people: 31    Probability: 0.919063161
Number of people: 32    Probability: 0.928791992
Number of people: 33    Probability: 0.944659069

REPLY [6 votes]: NB: I worked earlier on this problem and came up with the following solution. The first answer that was posted made me think that I got something wrong, and I discarded my work. Since the new answer by Moron agrees (essentially) with my previous work here it is, a slightly different derivation of the same formula.
Let $k$ be the number of days in a year. Let $m$ be the distinct number of birthdays among the $n$ friends. Let's assume that $k$ is big enough to have a non-trivial problem (say, $k > n/2$)
We're interested in binary strings with these three conditions:

Are of length $k$, with $m$ ones and $k-m$ zeros.
There's at least one zero between any two ones.
Condition 2 holds when "wrapping around" the string.

Let's count them by constructing them with the following algorithm:

Start with a string of $m$ ones: $11\dots 1$
There are now three distinct cases: there's a birthday on the first day of the year, there is a birthday on the last day of the year, there's a birthday on neither.
In the first case we have to distribute $k-m$ zeros in $m$ non-empty buckets. Those are called compositions, and one can show that there are $\binom{k-m-1}{m-1}$ such assignments.
The second case is analogous, giving another $\binom{k-m-1}{m-1}$ possible strings.
The third case is similar, giving instead $\binom{k-m-1}{m}$ strings.

Putting this together we have: $$2\cdot \binom{k-m-1}{m-1}+\binom{k-m-1}{m}$$
Since $n$ friends share $m$ birthdays we have to account for that, giving this expression:
$$p(n,k) =\frac{\sum_{m=1}^n{ m! \cdot S(n,m)\cdot \Bigg (2\cdot \binom{k-m-1}{m-1}+\binom{k-m-1}{m}}\Bigg )}{k^n}$$
where $S(n,m)$ is the Stirling number of the second kind. 
@Moron: Why do we need to multiply by $m!$ here? Oh right! Stirling numbers of the second kind count the number of coalitions, but we care about their order, too!