Click here to Skip to main content
15,885,537 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need to create a power function in oz by by reusing the intermediate results. For example, calculating 2^8 in 3 calculations by saying 2^2 = 2*2, 2^4 = 2^2 * 2^2, 2^8 = 2^4 * 2^4. What I have so far:
HTML
declare
proc  {Powerp N M K}
    if M == 0 then K = 1
    elseif M == 1 then K = N
    else
      {Powerp K M-1 K}
      K = N*N
    end
end

It is accepted by emacs but wont display a value in the browser. The input looks something like this:
{Browse {Powerp 2 3}}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900