Code a puzzle 4 Xmas
According to the traditional song, on the first day of Christmas (25th December), my true love sent to me:
On the second day of Christmas (26th December), my true love sent to me THREE presents:
On the third day of Christmas (27th December and so on) my true love sent to me SIX presents:
This carries on until the the twelfth day of Christmas, when my true love sends me:
Puzzle Author: Stephen Froggatt
2. Generalizing the function for any number of days:
```
Meanwhile, I invite you all to post in the comments some solution coded in the programming language of your choice
#math #puzzle #invitation #teaser #programmers #programming #code #christmas #days
@Pat I assure you do not have to to go back to the 70s to write a solution. π
I first went to Mathlab, but then thought it would be more fun to use something completely unsuited to the task, like AWK or BASH.
Are you looking for code for a function similar to the hard-coded solution in your example, or are you looking for some kind of mathematical shortcut using factorials or calculus or something?
(I’m not a math gal but I’m sure this must be a well-known series in mathematics, with the name of some old mathematician tacked on to it.)
@Pat
You may find it hard to believe, but I’m making this for fun, in the spirit of the season.
As you’ve been so kind to offer me the choice, AWK please. π
(Yes, it’s similar to “a well known series in mathematics, with the name of some old mathematician…” π€ )