fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. public class RecursionExample3 {
  8. static int factorial(int n){
  9. if (n == 1)
  10. return 1;
  11. else
  12. return(n * factorial(n-1));
  13. }
  14.  
  15. public static void main(String[] args) {
  16. System.out.println("Factorial of n is: "+factorial(n));
  17. }
  18. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:7: error: class RecursionExample3 is public, should be declared in a file named RecursionExample3.java
public class RecursionExample3 {  
       ^
Main.java:16: error: cannot find symbol
System.out.println("Factorial of n is: "+factorial(n));  
                                                   ^
  symbol:   variable n
  location: class RecursionExample3
2 errors
stdout
Standard output is empty