How would I know how many recursive calls were needed to solve a given base and exponent in the following program? Could I just add a "counter++" inside the powers function and get the correct answer by looking at what counter ends up being? This is what I tried:
Wouldn't that give me one more than what is really true? I say this because counter gets incremented immediately when entering the function, should it be counted the very first time we enter the function, even though we haven't recursively called anything yet?
Are you trying to count how many times the function powers is called, or how many times it calls itself (which will be how many times it is called, minus one)?