blob: a5c73f30a7e04d6bd1155f747d90f81df8219fc4 (
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
|
package test1;
public class Cflow {
public int run() {
return k1(4);
}
public int run2() {
return fact(5);
}
public int fact(int n) {
if (n <= 1)
return n;
else
return n * fact(n - 1);
}
public int k1(int i) {
if (i > 1)
return k2(i - 1);
else if (i == 1)
return i;
else if (i == 0)
throw new RuntimeException();
else
return -i;
}
public int k2(int i) {
if (i > 1)
return k1(i - 1);
else if (i == 1)
return i;
else if (i == 0)
throw new RuntimeException();
else
return -i;
}
}
|