22 lines
418 B
C++
22 lines
418 B
C++
#include <iostream>
|
|
#include <cmath>
|
|
using namespace std;
|
|
|
|
int ack(int i, int j){
|
|
if(i == 1 && j >= 1)
|
|
return pow(2,j);
|
|
if(i >=2 && j == 1)
|
|
return ack(i - 1, 2);
|
|
if(i >= 2 && j >= 2)
|
|
return ack(i - 1, ack(i, j - 1));
|
|
return 0;
|
|
}
|
|
|
|
int main(){
|
|
cout << "1,2: " << ack(1,2) << endl;
|
|
cout << "2,1: " << ack(2,1) << endl;
|
|
cout << "2,2: " << ack(2,2) << endl;
|
|
cout << "1,3: " << ack(1,3) << endl;
|
|
return 0;
|
|
}
|