find ackerman function recursive c 2b 2b

Solutions on MaxInterview for find ackerman function recursive c 2b 2b by the best coders in the world

showing results for - "find ackerman function recursive c 2b 2b"
Lucas
28 Jan 2021
1#include <iostream>
2using namespace std;
3
4int ack(int m, int n)
5{
6    if (m == 0){
7        return n + 1;
8    }
9    else if((m > 0) && (n == 0)){
10        return ack(m - 1, 1);
11    }
12    else if((m > 0) && (n > 0)){
13        return ack(m - 1, ack(m, n - 1));
14    }
15}
16
17int main()
18{
19    int ans,m,n;
20    cout<<"Enter the M and N with space :";
21    cin>>m>>n;
22    ans = ack(m, n);
23    cout << ans << endl;
24    return 0;
25}
26