New
This commit is contained in:
@@ -1,6 +1,21 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <cmath>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
int main(){
|
|
||||||
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
BIN
Recursion/P29_22_Ackermann.exe
Normal file
BIN
Recursion/P29_22_Ackermann.exe
Normal file
Binary file not shown.
1
Recursion/P29_23_GCD.cpp
Normal file
1
Recursion/P29_23_GCD.cpp
Normal file
@@ -0,0 +1 @@
|
|||||||
|
#include <iostream>
|
Reference in New Issue
Block a user