Last active
February 15, 2017 18:19
-
-
Save aarohmankad/dff293ece4eb36adb5ebd47b9b7dc565 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double ackermann(double m, double n) { | |
if (m == 0) { | |
return n + 1; | |
} else if (n == 0) { | |
return ackermann(m - 1, 1); | |
} | |
return ackermann(m - 1, ackermann(m, n - 1)); | |
} | |
int main(int argc, char const *argv[]) { | |
cout << ackermann(1, 4) << endl; // Output: 6 | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment