Guest User

Untitled

a guest
Jan 18th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import java.io.*;
  2. import java.math.*;
  3. import java.util.*;
  4.  
  5. public class Main{
  6. public static void main(String[] args) {
  7.  
  8. Scanner in = new Scanner((System.in));
  9. int i = in.nextInt();
  10. int cont=1;
  11. while (cont<=i) {
  12. int a = in.nextInt();
  13. BigInteger resul=factorial(BigInteger.valueOf(a));
  14. System.out.println(resul);
  15. cont++;
  16. }
  17.  
  18.  
  19. }
  20. public static BigInteger factorial(BigInteger n){
  21. BigInteger resultado;
  22. BigInteger cero=BigInteger.ZERO;
  23. BigInteger m = n.subtract(BigInteger.ONE);
  24. if(n==cero){
  25. resultado=BigInteger.ONE;
  26. }else{
  27. resultado=n.multiply(factorial(m));
  28. }
  29. return resultado;
  30. }
  31. }
Add Comment
Please, Sign In to add comment