Live Batches
Masterclasses
Menu
Free Courses
Account
Login / Sign Up

Smallest factorial number

Medium Acceptance 38.79% Points 30

Given a number n. The task is to find the smallest number whose factorial contains at least n trailing zeroes.

Examples
Example 1

Example 1

Input: n = 1

Output: 5

Explanation: 5! = 120 which has at least 1 trailing 0.

Example 2

Example 2

Input: n = 6

Output: 25

Explanation: 25! has at least 6 trailing 0.

Constraints
  • 1 <= n <= 10^4
Hints
  • Expected Time Complexity: O(log2 N * log5 N).
  • Expected Auxiliary Space: O(1).
Topics
Searching Algorithms
Companies
Apple Visa Walmart
Added 31 Dec 2024 38.79% acceptance
Ln 1, Col 1Sign in to save your code
1
5