fork download
  1. import java.util.Scanner;
  2. import java.math.BigInteger;
  3.  
  4. public class factorial {
  5. public static BigInteger factorial(int num){
  6. BigInteger fact = BigInteger.valueOf(1);
  7. for (int i = 1; i <= num; i++)
  8. fact = fact.multiply(BigInteger.valueOf(i));
  9. return fact;
  10. }
  11.  
  12. public static void main(String[] args) throws java.lang.Exception{
  13. Scanner input = new Scanner(System.in);
  14. int x;
  15. x = input.nextInt();
  16. System.out.println(factorial(x));
  17. }
  18. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
1
compilation info
Main.java:4: error: class factorial is public, should be declared in a file named factorial.java
public class factorial {
       ^
1 error
stdout
Standard output is empty