Skip to content

Commit 6ee7b78

Browse files
committedFeb 2, 2025
Add solution #172
1 parent e293e01 commit 6ee7b78

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed
 

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
168|[Excel Sheet Column Title](./0168-excel-sheet-column-title.js)|Easy|
165165
169|[Majority Element](./0169-majority-element.js)|Easy|
166166
171|[Excel Sheet Column Number](./0171-excel-sheet-column-number.js)|Easy|
167+
172|[Factorial Trailing Zeroes](./0172-factorial-trailing-zeroes.js)|Medium|
167168
173|[Binary Search Tree Iterator](./0173-binary-search-tree-iterator.js)|Medium|
168169
179|[Largest Number](./0179-largest-number.js)|Medium|
169170
187|[Repeated DNA Sequences](./0187-repeated-dna-sequences.js)|Medium|
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* 172. Factorial Trailing Zeroes
3+
* https://leetcode.com/problems/factorial-trailing-zeroes/
4+
* Difficulty: Medium
5+
*
6+
* Given an integer n, return the number of trailing zeroes in n!.
7+
*
8+
* Note that n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1.
9+
*/
10+
11+
/**
12+
* @param {number} n
13+
* @return {number}
14+
*/
15+
var trailingZeroes = function(n) {
16+
return n < 5 ? 0 : Math.floor(n / 5) + trailingZeroes(n / 5);
17+
};

0 commit comments

Comments
 (0)
Please sign in to comment.