Skip to content

Instantly share code, notes, and snippets.

@jmcph4
Created January 12, 2015 09:51
Show Gist options
  • Select an option

  • Save jmcph4/8071da525ebb695d111a to your computer and use it in GitHub Desktop.

Select an option

Save jmcph4/8071da525ebb695d111a to your computer and use it in GitHub Desktop.
#include <iostream>
unsigned int A(unsigned int m, unsigned int n)
{
// std::cout << "A(" << m << "," << n << ")" << std::endl;
if(m == 0)
{
return n + 1;
}
else
{
if(n == 0)
{
return A(m - 1, 1);
}
else
{
return A(m - 1, A(m, n - 1));
}
}
}
int main(int argc, char** argv)
{
if(argc == 3)
{
unsigned int m = atoi(argv[1]);
unsigned int n = atoi(argv[2]);
std::cout << A(m, n) << std::endl;
return 0;
}
else
{
std::cerr << argv[0] << " m n" << std::endl << "where m and n are non-negative integers" << std::endl;
return 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment