**C Program to implement Ackermann function **

**C Program to implement Ackermann function**

Write a C Program to implement Ackermann function using recursion. Here’s simple Program to implement Ackermann’s function using recursion in C Programming Language.

**Recursion : :**

**Recursion : :**

- Recursion is the process of repeating items in a self-similar way. In programming languages, if a program allows you to call a function inside the same function, then it is called a
of the function.**recursive call**

- The C programming language supports recursion, i.e., a function to call itself. But while using recursion, programmers need to be careful to define an exit condition from the function, otherwise it will go into an infinite loop.

- Recursive functions are very useful to solve many mathematical problems, such as calculating the factorial of a number, generating Fibonacci series, etc.

*Ackermann Function*

*Ackermann Function*

The Ackermann function is the simplest example of a well-defined total function which is computable but not primitive recursive, providing a counterexample to the belief in the early 1900’s that every computable function was also primitive recursive . It grows faster than an exponential function, or even a multiple exponential function.

Below is the source code for C Program to implement Ackermann function using recursion which is successfully compiled and run on Windows System to produce desired output as shown below :

**SOURCE CODE : :**

**SOURCE CODE : :**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
/* C Program to implement Ackermann function using recursion */ #include<stdio.h> int A(int m, int n); main() { int m,n; printf("Enter two numbers :: \n"); scanf("%d%d",&m,&n); printf("\nOUTPUT :: %d\n",A(m,n)); } int A(int m, int n) { if(m==0) return n+1; else if(n==0) return A(m-1,1); else return A(m-1,A(m,n-1)); } |

**OUTPUT : :**

**OUTPUT : :**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
************* OUTPUT ************** ************* FIRST RUN *********** Enter two numbers :: 1 0 OUTPUT :: 2 ************* SECOND RUN *********** Enter two numbers :: 0 5 OUTPUT :: 6 |

If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may * Contact Us* through our contact Page or you can also comment below in the comment section.We will try our best to reach upto you in the short interval.

**Thanks for reading the post….**