Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
890 B
2
Indexable
Never
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
import java.util.Scanner;
public class Main {
    public static Scanner cin = new Scanner(System.in);
    public static int factorialInt(int n)
    {
        if (n <= 1)
            return 1;
        return n * factorialInt(n - 1);
    }
    public static BigInteger factorialBigInt(BigInteger n)
    {
        if (n.equals(BigInteger.ZERO))
            return BigInteger.ONE;
        return n.multiply(factorialBigInt(n.subtract(BigInteger.ONE)));
    }
    public static BigDecimal e(BigDecimal n)
    {
        
    }
    public static void main(String[] args)
    {
        int n;
        n = cin.nextInt();
        System.out.println(factorialInt(n));
        BigInteger n2;
        n2 = cin.nextBigInteger();
        System.out.println(factorialBigInt(n2));
    }
}
Leave a Comment