blob: fce6be3e8841be42e31804a23b4ff809a9ee593c (
plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
public class Main {
public static void main(String[] args) {
System.out.println(mult(6, 5));
}
private static long fakultaet(long z) {
if(z != 0) return z*fakultaet(z-1);
return 1;
}
private static int fibonacci(int i) {
if(i == 0) return 0;
if(i == 1) return 1;
return fibonacci(i-1) + fibonacci(i-2);
}
private static int nachfolger(int z) {
return z+1;
}
private static int sum(int n, int m) {
if(m == 0) return n;
return sum(nachfolger(n), m-1);
}
private static int mult(int n, int m) {
if(m == 0) return n;
return sum(mult(n, m-1), n);
}
private static int acker(int x, int y) {
if(x == 0) return y+1;
if(y == 0) return acker(x-1, y);
return acker(x-1, acker(x, y-1));
}
private static int ulam(int x) {
if(x == 1) return 1;
if(x > 1) {
if(x%2 == 0) {
return ulam(x/2);
} else {
return ulam((3*x)+1);
}
}
return -1;
}
}
|