Created
June 16, 2017 23:22
-
-
Save oliverbooth/9c7fd67105663bb962b94f9fa2dc7b29 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/// <summary> | |
/// Calculates the Ackerman function for two values. | |
/// </summary> | |
/// <param name="m">The first value.</param> | |
/// <param name="n">The second value.</param> | |
/// <returns>Returns the result of the Ackerman function.</returns> | |
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)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment