C++: 2^n function for algorithm practice.