#include  <stdio.h>
#include  <conio.h>

int  ack(int  m, int  n)
{
    if(m==0)
        return  (n+1) ;
    else if(n==0 && m>0)
        return  ( ack(m-1,1) ) ;
    else
        return  ( ack(m-1, ack(m,n-1) ) );
}

void main()
{
    int  m, n ;
    clrscr() ;
    printf("Enter two numbers: ") ;
    scanf("%d %d", &m, &n) ;
    printf("Solution is %d", ack(m,n) ) ;
    getch() ;
}

Output :

Enter two numbers:  2 3
Solution is 9

Add a Comment

Add a Comment