summaryrefslogtreecommitdiff
path: root/libjava/testsuite/libjava.lang/inline.java
blob: 66585293491c5807b6e0f386588c619ec0ada9e5 (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
public class inline
{
  static int factorial_1 (int n)
  {
    if (n > 0)
      return n * factorial_1(n-1);
    return 1;
  }

  static int factorial_2 (int n)
  {
    if (n > 0)
      return n * factorial_3(n-1);
    return 1;
  }

  static int factorial_3 (int n)
  {
    if (n > 0)
      return n * factorial_2(n-1);
    return 1;
  }

  public static void main(String args[])
    {
      if (factorial_1 (5) != 120)
	System.out.println("This should not happen");
      else
	System.out.println("OK");
      if (factorial_2 (5) != 120)
	System.out.println("This should not happen");
      else
	System.out.println("OK");
    }
}