Problem 44068. The number of trailing zero digit of a factorial
For given positive integer n, take factorial of that number. How many trailing zeros does it have?
Example: factorial(11) = 39916800
Its last zero-digit count is 2.
Optional: Can you make an efficient algorithm for a very large n?
Solution Stats
Problem Comments
-
2 Comments
vpa(factorial(27)) = 10888869450418351940239884288
...
no trailing zeros
factorial(27) = 1.088886945041835e+28
...
vpa(factorial(27)) - 1.088886945041835e+28 - 2.199023255552000e+12 = 0
I don't get it.
if vpa(factorial) = 10888869450418351940239884288
then there are no trailing zeros...
vpa(factorial(11)) = 39916800
two trailing, like in your problem statement...
am I crazy?
Highphi, any factorial equal to or greater than 5! has to have trailing zeros because it will have one or more pairs of 2 and 5 in its factors. I think factorial(vpa(27)) will give the correct value.
Solution Comments
Show commentsProblem Recent Solvers61
Suggested Problems
-
Find all elements less than 0 or greater than 10 and replace them with NaN
15636 Solvers
-
The Goldbach Conjecture, Part 2
2372 Solvers
-
Similar Triangles - find the height of the tree
448 Solvers
-
Change the sign of even index entries of the reversed vector
576 Solvers
-
Create sequnce 1 4 9 16 25.........
395 Solvers
More from this Author9
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!