@ResidentBiscuit: Easy: either they are able to follow the code and learn something new for themselves or they submit it as a homework "solution" and deal with the consequences of clearly ignoring the material that was taught. Either experience is helpful.
Cubbi; you got me curious now. How would you deal with this without using this kind of recursion? Better yet, how would you recreate the double pow(double,double) function, which presumably doesn't do any nasty looping/recursion?
I'm gonna guess the answer is lookup tables, but I thought I'd ask..
@ausairman; that recursion can be trivially rewritten as a loop, at which point you will have reproduced your typical C math library pow() function for integer powers. Can't beat O(log n) complexity.
For pow(double, double), the usual library approach is to represent it in terms of available CPU instructions: x86 has base-2 logarithms, so it is calculated, roughly, as 2y log2x, see for example glibc source code sysdeps/i386/fpu/e_pow.S (note the integer power algorithm in the beginning of that file, which is the usual repeated squaring).
If nothing is avaiable, it is usually still done through logarithms, which are decomposed into sums of series and, you're right, lookup tables. Again if you have glibc source, check out sysdeps/ia64/fpu/e_pow.S for example.
Which does bring up the question: how far does "built-in function" go? I'd say "exp" and "log" were built-in functions, but I suppose technically operator+ and operator* are as well.
The lowest level of "built-in" is presumably the processor's instruction set; if we say anything apart from those are excluded, we're looking at something like this work of art