CB100

Notas, resueltos y tps de la materia Algoritmos y Estructuras de Datos
Index Commits Files Refs README
guias/3/ej06.cpp (338B)
   1 // https://en.wikipedia.org/wiki/Ackermann_function
   2 
   3 #include <iostream>
   4 
   5 unsigned int ackerman(unsigned int m, unsigned int n) {
   6     if(!m)
   7         return n + 1;
   8 
   9     if(!n)
  10         return ackerman(m-1, 1);
  11 
  12     return ackerman(m-1, ackerman(m, n-1));
  13 }
  14 
  15 
  16 int main (void) {
  17     std::cout << ackerman(3, 3) << std::endl;
  18 
  19     return 0;
  20 }