Student | Posted on
Before going to the question, we should know what is a factorial. The factorial is the product of the all positive Integers equals to or less than a certain given positive integer. It is donated by 'n'. The factorial is for all positive numbers including zero. It is important to note that it is less than or equal to n but greater than or equal to 1. But for the negative numbers, factorials are not defined. This factorial system is quite used in math a lot while calculating the numbers of possible combinations and permutations. The factorial system appears as the sequence of descending natural numbers in multiplication like 9×8×7×6× ....×1. The symbol used for factorial is!
The factorial formula used:-
n! = n × ( n-1 ) × ( n- 2 ) × (n -3 ).... 3× 2×1. [ Here n = natural number greater than or equal to 1].
By convection, n = 0, then n! = 1.
For example 7! = 7×6×5×4×3×2×1 = 5040.
Now coming to the question, the factory of 100 is rounded off to approximately 9.332615443944E +157.
The factorial of 100 is calculated according to the formula like 100! = 100× 99×98×97×96×95×94×……...×4×3×2×1.
The count of trailing zeros in 100! is 24. The number of digits is 158. It is nearly impossible to store these many digits even if we use " long long int. " But in Java, we have a " Biginteger ". Using this we can easily calculate.
Java implementation:-
import java. util.*;
import java. lang.*;
import java.io.*;
import java. math.*;
class Factorial Big Number
{
public static void main (String[] args) throws java. lang.Exception
{
BigInteger fact= BigInteger.ONE;
int factorial = 100;
for (int i = 2; i <= factorialNo; i++)
{
fact = fact.multiply(new BigInteger(String.valueOf(i)));
}
System.out.println("The factorial of " + factorialNo +" is: " + fact);
}
}
0 Comment
CONTENT WRITER | Posted on
What is the factorial of hundred?
The factorial of a number is the product of all natural numbers less that number, with each product rounded down to the nearest integer. The factorial of one, or 1!, is 1
The factorial of 20, or 20! would be:
20 x 19 x 18 x 17 x 16 x 15... etc
Factorials are calculated by multiplying a sequence of consecutive integers from least to greatest, so in this case 5! = 5 X 4 X 3 X 2 X 1 = 120 and 100! = 100 X 99 X 98... etc.
0 Comment