Debian Codegraph @

benchmarks.larceny/src/tak.java

raw
1 /* TAK -- A vanilla version of the TAKeuchi function. */
2
3 class tak {
4
5 static int tak (int x, int y, int z)
6 {
7 if (y >= x)
8 return z;
9 else
10 return tak (tak (x-1, y, z),
11 tak (y-1, z, x),
12 tak (z-1, x, y));
13 }
14
15 public static void main (String args[])
16 {
17 int i;
18 int result = 0;
19
20 for (i=0; i<1000; i++)
21 result = tak (18, 12, 6);
22
23 if (result != 7)
24 System.out.println ("*** wrong result ***");
25 }
26 }
27