Factorial Trailing Zeroes - aloalgo

Factorial Trailing Zeroes

Medium

You are given a non-negative integer n.

Your task is to determine the total number of trailing zeroes in the result of n! (n factorial).

Note that:

  • n! (n factorial) is defined as the product of all positive integers from 1 up to n.
  • For example, if n = 5, then 5! = 5 * 4 * 3 * 2 * 1 = 120.

Return the total number of trailing zeroes.

Example 1

Input
5
Output
1
Explanation:

5! = 120, which has one trailing zero.

Example 2

Input
10
Output
2
Explanation:

10! = 3,628,800, which has two trailing zeroes.

Example 3

Input
2
Output
0
Explanation:

2! = 4, which has no trailing zeroes.

Loading...
Input
5
Output
1

Hello! I am your ✨ AI assistant. I can provide you hints, explanations, give feedback on your code, and more. Just ask me anything related to the problem you're working on!