inline.java: New file.
2002-07-02 Andrew Haley <aph@redhat.com> * libjava.lang/inline.java: New file. * libjava.lang/inline.out: Likewise. * libjava.lang/Array_3.java: Add another case. From-SVN: r55186
This commit is contained in:
committed by
Andrew Haley
parent
49e7b251ee
commit
6ac0c1e36f
@@ -0,0 +1,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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user