Re: coconut problem solution code
- Posted by jzeitlin at cyburban.com Dec 16, 2001
- 407 views
On Sun, 16 Dec 2001 03:53:59 -0800, John McAdam <johnmcadam at clix.pt> wrote: >--This code works fine. >--Nice equation don't you agree? >--Thanks, I think so too. >atom morning_to_each_man >integer start_pile >for pile=1 to 1000 do > morning_to_each_man=((2*(((2*(((2*((pile-1)/3))-1)/3))-1)/3))-1)/3 > if integer(morning_to_each_man) then > start_pile=pile > exit > end if >end for >printf(1,"start pile = %d",start_pile) It certainly does work, though it took me three or four tries to parse that equation for correctness. Now, come up with a version that will tell you (a) how many coconuts each man got on that last morning (b) how many coconuts each man got, total. -- Jeff Zeitlin jzeitlin at cyburban.com (ILink: news without the abuse. Ask via email.)