Continued from the "Programming Homework" thread. Emporius started that thread asking help on writing a program that raises a number to an integer exponent.
It's not a hard problem, but it's the sort of little problem that can concisely show off a coder's style and approach to a problem.
So I'm interested to see how coders here would write the function, in any language:
power, a function that takes a real base and an integer exponent and returns the real equal to the base raised to the exponent power. (If you want, you can assume the exponent to be unsigned.)
Don't worry if your solution isn't as good as someone else's. The point isn't to write the perfect power function, it's to show how you'd do it.
It's not a hard problem, but it's the sort of little problem that can concisely show off a coder's style and approach to a problem.
So I'm interested to see how coders here would write the function, in any language:
power, a function that takes a real base and an integer exponent and returns the real equal to the base raised to the exponent power. (If you want, you can assume the exponent to be unsigned.)
Don't worry if your solution isn't as good as someone else's. The point isn't to write the perfect power function, it's to show how you'd do it.