-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAckermannFunction.java
More file actions
33 lines (30 loc) · 1002 Bytes
/
Copy pathAckermannFunction.java
File metadata and controls
33 lines (30 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**************************************
in diesem Kommentar bitte Antwort zu Teil (2) und (3) einfuegen
***********************************************/
import java.math.BigInteger;
public class AckermannFunction {
public static BigInteger ackermann(BigInteger x, BigInteger y){
int cntrl1=Integer.parseInt(x.toString());
int cntrl2=Integer.parseInt(y.toString());
BigInteger zero= new BigInteger("0");
BigInteger one= new BigInteger("1");
BigInteger two= new BigInteger("2");
if(y.equals(zero)==true) {
return zero;
}
else if(x.equals(zero)==true) {
return y=y.multiply(two);
}
else if(y.equals(one)==true) {
return two;
}
else{
return ackermann(x.subtract(one), ackermann(x, y.subtract(one)));
}
}
public static void main(String[] args) {
BigInteger x=new BigInteger("1");
BigInteger y= new BigInteger("10");
System.out.println(ackermann(x, y).toString());
}
}