Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.math.*;
- import java.util.*;
- public class Main{
- public static void main(String[] args) {
- Scanner in = new Scanner((System.in));
- int i = in.nextInt();
- int cont=1;
- while (cont<=i) {
- int a = in.nextInt();
- BigInteger resul=factorial(BigInteger.valueOf(a));
- System.out.println(resul);
- cont++;
- }
- }
- public static BigInteger factorial(BigInteger n){
- BigInteger resultado;
- BigInteger cero=BigInteger.ZERO;
- BigInteger m = n.subtract(BigInteger.ONE);
- if(n==cero){
- resultado=BigInteger.ONE;
- }else{
- resultado=n.multiply(factorial(m));
- }
- return resultado;
- }
- }
Add Comment
Please, Sign In to add comment