> For the complete documentation index, see [llms.txt](https://mayanktyagi3111.gitbook.io/interview-prep/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mayanktyagi3111.gitbook.io/interview-prep/maths/trailing-zeros-in-factorial.md).

# Trailing Zeros in Factorial

Given an integer **A**, return the number of trailing zeroes in A!.

**Note**: Your solution should be in logarithmic time complexity.\
\
\*\***Problem Constraints**\*\*

1 <= A <= 10000\
\
\*\***Input Format**\*\*

First and only argumment is integer A.\
\
\*\***Output Format**\*\*

Return an integer, the answer to the problem.\
\
\*\***Example Input**\*\*

**Input 1:**

```
 A = 4
```

**Input 2:**

```
 A = 5
```

\
\*\***Example Output**\*\*

**Output 1:**

```
 0
```

**Output 2:**

```
 1
```

\
\*\***Example Explanation**\*\*

**Explanation 1:**

```
 4! = 24
```

**Explanation 2:**

```
 5! = 120
```

```java
public class Solution {
    public int trailingZeroes(int A) {
        if (A < 5)
            return 0;
        return (A / 5) + trailingZeroes(A / 5);
    }
}
```
