Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Christmas Math Fun
Message
De
10/12/1997 12:57:36
Matt Mc Donnell
Mc Donnell Software Consulting
Boston, Massachusetts, États-Unis
 
 
À
10/12/1997 12:52:37
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00064933
Message ID:
00065057
Vues:
39
>>>>>>>>On the 1st day of Xmas, my true love gave to me:
>>>>>>>>1 item
>>>>>>>>On the 2nd day of Xmas, my true love gave to me:
>>>>>>>>2 items + 1 item
>>>>>>>>On the 3rd day of Xmas, my true love gave to me:
>>>>>>>>3 items + 2 items + 1 item
>>>>>>>>.
>>>>>>>>.
>>>>>>>>On the n-1 day of Xmas, my true love gave to me:
>>>>>>>>n-1 items + n-2 items + ... + 1 item
>>>>>>>>On the nth day of Xmas, my true love gave to me:
>>>>>>>>n items + n-1 items + ... + 1 item
>>>>>>>>
>>>>>>>>How many total items did my true love give to me, as a function of n?
>>>>>>>
>>>>>>>Number of gifts = gifts(n)
>>>>>>>
>>>>>>>
>>>>>>>FUNCTION gifts(n)
>>>>>>>lnReturn = 0
>>>>>>>FOR I = 1 TO n
>>>>>>> FOR H = 1 TO I
>>>>>>> lnReturn = lnReturn + H
>>>>>>> ENDFOR
>>>>>>>ENDFOR
>>>>>>>RETURN lnReturn
>>>>>>>
>>>>>>>
>>>>>>>not arithmetic, but it works
>>>>>>
>>>>>>Er, yes, but there is an elegant mathematical solution that even a computer would like! (no looping involved)
>>>>>
>>>>>
>>>>>Maybe it can be : Gifts = (n+1) * (n/2) ??
>>>>
>>>>Um, no, we've seen that one earlier...that's not the cumulative sum for all the days, that's only one day...
>>>
>>>Sum=(N^3)/6+(N^2)/2+N/3
>>>If this is right, I will send you bill ::)
>>
>>I guess this is pretty much the same thing, but this is what I came up with:
>>(N*(N+2)/3)*(N+1)/2
>
>For N=12;&&Number of days of christmas
>sum = 364
>
>True love should have just given one gift a day on every day of the year except christmas day, and saved all the trouble.

Does that prove that the person who wrote the 12 days of Christmas was a mathematician? Numbers are so fun. And, Eric you're absolutely right, we're all nerds! lol
Matt McDonnell
...building a better mousetrap with moldy cheese...
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform