Home Segments Index Top Previous Next

340: Mainline

To define recursive_power_of_2, you can take advantage of the power_of_2 function already provided in Chapter 20.

Given that power_of_2 exists, one way to define recursive_power_of_2 is to hand over the real work to power_of_2 as follows:

int recursive_power_of_2 (int n) {
  return power_of_2 (n);  
} 

Once you see that you can define recursive_power_of_2 in terms of power_of_2, you are ready to learn how gradually to turn recursive_power_of_2 into a recursive function that does not rely on power_of_2.