My dad and I were bored at a Christmas concert lately, so we started
talking about how many items you receive in the 12 days of Christmas.
You get 1 item on day 1, 3 items on day 2, 6 on day 3, etc. We
figured that out pretty easily, but then we were trying to come up
with a closed form solution for any number of days.
When I got home and had some paper to work with I managed to do it,
but I felt like my approach wasn't very nice.
So, can you find a solution, and more importantly do you know an
elegant way to do it?
If you're not familiar with the song, you can find the basic structure of the lyrics on Wikipedia, or just Google "the 12 days of Christmas" and you'll find it.
Just to be clear, it is a cumulative song, so you receive one partridge in a pear tree on the first day, then on the second day you receive two turtle doves and another partridge in a pear tree, for a total of four items on the first two days, and so on for twelve days. The puzzle is to find out how many gifts you receive in total for all twelve days (not just on the twelfth day), and to find an elegant way to calculate the number of gifts you'd receive if the number of days is extended beyond twelve.
You can see the solution here.