Re: coconut problem solution code

new topic     » goto parent     » topic index » view thread      » older message » newer message

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.)

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu