CB100

Notas, resueltos y tps de la materia Algoritmos y Estructuras de Datos
Index Commits Files Refs README
guias/3/ej02.cpp (296B)
   1 #include <iostream>
   2 
   3 // If called without an exponent value it returns the number squared
   4 int pow_r(int x) {
   5     return x*x;
   6 }
   7 
   8 int pow_r(int x, int y) {
   9     if(y == 0)
  10         return 1;
  11 
  12     return x*pow_r(x, y-1);
  13 }
  14 
  15 int main (void) {
  16     std::cout << pow_r(2, 8) << std::endl;
  17     return 0;
  18 }