Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Christmas Math Fun
Message
 
To
10/12/1997 08:28:27
Matt Mc Donnell
Mc Donnell Software Consulting
Boston, Massachusetts, United States
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00064933
Message ID:
00064964
Views:
37
>>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)
The Anonymous Bureaucrat,
and frankly, quite content not to be
a member of either major US political party.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform