How many gifts? The Twelve Days of Christmas is a cumulative song , meaning that
Question:
How many gifts?
"The Twelve Days of Christmas" is a cumulative song, meaning that each verse is built on top of the previous verses. There are twelve verses, each describing a gift given by "my true love" on one of the twelve days of Christmas.
The first three verses run, in full, as follows:
On the first day of Christmas my true love sent to me
A partridge in a pear tree. ( Note - So 1 gift was given)
On the second day of Christmas my true love sent to me
Two turtle doves
And a partridge in a pear tree. (So 2 + 1 gifts were given)
On the third day of Christmas my true love sent to me
Three French hens,[5]
Two turtle doves,
And a partridge in a pear tree. (So?)
Subsequent verses follow the same pattern, each adding one new gift and repeating all the earlier gifts so that each verse is one line longer than its predecessor:
? 4 calling birds
? 5 gold rings
? 6 geese a-laying
? 7 swans a-swimming
? 8 maids a-milking
? 9 ladies dancing
? 10 lords a-leaping
? 11 pipers piping
? 12 drummers drumming
Please create an algorithm that outputs the total number of gifts given on each day. Express your algorithm in the following 3 ways:
- Summation using sigma notation
- Pseudo-code
- Program in C++ or Python
Express the time complexity of your algorithm in Big-O notation
For the pseudo code style, using this module
Make sure your program:
- Compiles and runs without hanging or errors
- Is commented in a professional manner