S
S
sr362020-02-03 12:58:44
Java
sr36, 2020-02-03 12:58:44

Why is there a lot of zeros at the end of the factorial calculation?

There is a simple factorial calculation code using BigInteger

BigInteger res = BigInteger.ONE;
    
    int n = 100;
    
    for(int i = 1; i <= n; i++) {
        res = res.multiply(BigInteger.valueOf(i));
    }
    
    System.out.print(res);

When calculating the factorial of the number we get with a lot of zeros at the end

of 961446671503512660926865558697259548455355905059659464369444714048531715130254590603314961882364451384985595980362059157503710042865532928000000000000000000000000

Why is this happening?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Shitskov, 2020-02-03
@sr36

Because starting from 5! all factorials end in zero (or zeros).
See table of values
​​https://ru.wikipedia.org/wiki/%D0%A4%D0%B0%D0%BA%D...
PS it looks like your value is incorrect

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question