KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Recurse1


1 public class Recurse1 {
2
3     public static void main(String JavaDoc [] args){
4         Recurse1 r = new Recurse1();
5         System.out.println(r.fact(9));
6     }
7
8     public int fact(int n){
9         if (n > 1) {
10             return n * fact(n-1);
11         }
12         else {
13             return 1;
14         }
15     }
16 }
17
Popular Tags