Maker Pro
Maker Pro

the twelve days of christmas?

Greetings from Penn's woods.

How would you calculate the number of gifts in the song "The Twelve Days of Christmas" ?

I would think it is the sum of gifts+days as gifts goes from 1 to 12 and as days goes from 12 to 1.
That is as far as i can get. You do not get any credit unless you show your work ;)
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
I was thinking 13*6, but your explanation is better than I would have given.
 
Yes but you did not show how to calculate it - so no credit.
I was wrong it is not the sum of gifts and days but the product:
sum = sum + (gifts++ * days-- )

day gifts days
1 1 12 = 12
2 2 11 = 22
3 3 10 = 30 and so on but what is the mathematical expression?
 
that works:

Private Sub Command2_Click()
Dim gifts As Integer
Dim sum As Integer

For gifts = 1 To 12 Step 1
sum = sum + (gifts * (gifts + 1)) / 2
Next gifts

Text2.Text = Str(sum) 'sum = 364
End Sub
 
in this one it is easier to see the gifts go up and the days go down.
Private Sub Command1_Click()
Dim days As Integer
Dim gifts As Integer
Dim sum As Integer
days = 12
For gifts = 1 To 12 Step 1
sum = sum + gifts * days
days = days - 1
Next gifts
Text1.Text = Str(sum)
End Sub
 
Top