Write a Java program to print the factorial of an integer number. Example- Factorial of 5= 5*4*3*2*1=120, Factorial 0f 7= 7*6*5*4*3*2*1= 5040
Answers
Answered by
0
Answer:
Explanation:
Find Factorial of a number using BigInteger
import java.math.BigInteger;
public class Factorial {
public static void main(String[] args) {
int num = 30;
BigInteger factorial = BigInteger.ONE;
for(int i = 1; i <= num; ++i)
{
// factorial = factorial * i;
factorial = factorial.multiply(BigInteger.valueOf(i));
}
System.out.printf("Factorial of %d = %d", num, factorial);
}
}
Similar questions