Skip to content

Instantly share code, notes, and snippets.

@codepainkiller
Created October 5, 2014 02:46
Show Gist options
  • Save codepainkiller/b3794b97c07c9ba5d2e1 to your computer and use it in GitHub Desktop.
Save codepainkiller/b3794b97c07c9ba5d2e1 to your computer and use it in GitHub Desktop.
Función de Ackerman - C++
#include <iostream>
#include <cstdlib>
using namespace std;
int Ackerman(int m, int n)
{
if(m==0)
return n+1;
else
{
if(n==0)
return Ackerman(m-1, 1);
else
return Ackerman(m-1, Ackerman(m, n-1));
}
}
int main()
{
int m, n, num ;
cout<<"\n FUNCION DE ACKERMAN \n\n";
cout<<"Ingrese <m>: ";
cin>> m ;
cout<<"Ingrese <n>: ";
cin>> n ;
num = Ackerman(m,n);
cout<<"\nEl numero es: "<< num <<endl<<endl;
system("pause");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment