coconut challenge solution

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

-- Does exactly the same but uses while loops like asked
integer num
atom coconuts
num = 1
while 1 do
    coconuts = ((((3 * (num) + 1) / 2 * 3 + 1) / 2 * 3 + 1) / 2 * 3 + 1)
    if coconuts = floor(coconuts) then
	exit
    else
	num += 1
    end if
end while
printf(1, "The number of coconuts they collected is %d.", coconuts)

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

Search



Quick Links

User menu

Not signed in.

Misc Menu