Factorial Trailing Zeros Problem

You are provided with a positive integer N. Your goal is to determine the smallest number whose factorial has at least N trailing zeros.

Example:

Input:
N = 1
Output:
5
Explanation:

The factorial of 5 (5!) is 120, which contains at least 1 trailing zero, making it the smallest such number.

Input:

The first line contains an integer 'T' indicating the number of test cases. Each test case consists of a single integer 'N' representing the required number of trailing zeros.

Output:

For each test case, output the smallest number whose factorial contains at least N trailing zeros. Each result should be on a new line.

Constraints:

  • 1 <= T <= 10
  • 0 <= N <= 108
  • Time Limit: 1 sec

Note:

You do not need to print anything. Just compute and return the result.
Be the first one to answer
Add answer anonymously...
Salesforce Associate Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter