Number of gifts
This program was created because of the question "Can math be applied to the song Twelve Day of Christmas?" The program assumes that a partridge and a pear tree count as one gift for simplicity's sake and because the wording says a partridge IN a palm tree, not a partridge AND a pear tree. The program only works if you input a positive whole number like 863. -452, 86.4, and 2^82589933-1 does not work. I discovered that to get the number of gifts given on a certain day you just add the day number to the number of gifts given the previous day. The recursive formula is f(x)=f(x-1)+x with f(0)=0. For people who look at the code: d(x)=(x^2+x)/2 calculates how many gifts you get per day. This assumes that every time a gift is mentioned it is given. So, on day 2 you get 3 gifts because you get 1 partridge in a pear tree and 2 turtle doves. t(x)=-(x^2)+(g+1)x calculates the amount given over the entire time for each gift. g is a constant and equals how many days gifts are given. For g=12, you get 12 partridges in pear trees and 22 turtle doves because you get 1 partridge in a pear tree and 2 turtle doves for 11 days. t(x) needs x to be multiplied by (g+1) instead of g to be accurate.
Created October 17, 2021
Last updated February 6, 2025
Published February 6, 2025