Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Finding trailing zeros of a factorial JavaScript
Given an integer n, we have to write a function that returns the number of trailing zeroes in n!.
For example −
trailingZeroes(4) = 0 trailingZeroes(5) = 1 because 5! = 120 trailingZeroes(6) = 1
Example
const num = 17;
const findTrailingZeroes = num => {
let cur = 5, total = 0;
while (cur Output
And the output in the console will be −
3
1
0
Advertisements
