# On the Nth day of Christmas, I got thinking about calculus…

Cumulatively, on the nth day of Christmas, my true love will have given me n(n+1)/2 presents.  Something I had to think quite hard about, because I’m not really a mathematician (as will probably be evident in what follows).  But in thinking about it I came to appreciate the beauty of graphs and calculus a little bit more, so maybe it’s worth sharing.

 N 1 2 3 4 5 6 7 … Presents 1 2 3 4 5 6 7 … Cumulative presents 1 3 6 10 15 21 28 …

Because the progression is linear, the mean and median of the presents sequence are identical.  The sum of the numbers of the sequence at any particular point is therefore equal to the product of the median and n (mean=sum/n, sum=mean*n, and mean=median).  The median is (n+1)/2 , so the cumulative number of presents (sum) =n(n+1)/2.  Simple.

The graph below of n against p (instantaneous presents) shows the same concept geometrically.  The area under the slope is the same as the area under the horizontal line which intersects the slope at its midpoint (median). The area, however, is less the cumulative present number by n/2, because… Alternatively, S n dn = (n^2)/2.  Plus the half-n.

That’s all.  Happy Christmas.

EDIT: just to open up a whole new discipline, here‘s the formula in a handy bit of java script courtesy of a talented friend, Jamie Dumont.