Smallest n, for n! to have m trailing zero digits - MATLAB Cody - MATLAB Central

Problem 44071. Smallest n, for n! to have m trailing zero digits

Difficulty:Rate
For given positive integer n, its factorial often has many trailing zeros, in other words many factors of 10s. In order for n! to have at least "m" trailing zeros, what is the smallest "n" ?
Example: factorial(10) = 3628800 factorial(9) = 362880 In order to have 2 trailing zeros on factorial, the smallest n is 10.
Optional: Can you make an efficient algorithm for a very large m?

Solution Stats

60.8% Correct | 39.2% Incorrect
Last Solution submitted on Apr 25, 2025

Problem Comments

Solution Comments

Show comments
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
3

Problem Recent Solvers53

Suggested Problems

More from this Author9

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Go to top of page