Powers of 5
- From: "Josh" <jzenker@xxxxxxxxx>
- Date: 4 Sep 2006 16:15:39 -0700
Hi, I'm an undergrad studying computer science. I discovered, while
studying for a computer science final, that I still haven't come up
with an answer to a question that was offered as extra credit on our
first quiz in the course. We were given the following Pascal code.
function power(n: integer): integer;
begin
if n <= 1 then
return (5)
else
return (5 * power(n-1))
end; {power}
We were then asked: "Can you modify the function in such a way that for
arguments of the form 2^k it computes the result with just k+1 calls?"
I'm not especially adept with math, and I have no idea how to approach
the question. Please point me in the right direction; I would really
like to understand this.
--
Josh Zenker
.
- Follow-Ups:
- Re: Powers of 5
- From: John Schutkeker
- Re: Powers of 5
- From: Phil Carmody
- Re: Powers of 5
- From: Rick Decker
- Re: Powers of 5
- Prev by Date: Re: Am I a crank?
- Next by Date: Re: An uncountable countable set
- Previous by thread: group theory question
- Next by thread: Re: Powers of 5
- Index(es):