Source: Codewars

The Challenge: Write a program that will calculate the number of trailing zeros in a factorial of a given number.

function zeros(n) {
  let zeros = Math.floor(n / 5);
  for (let x = 2; 5 ** x <= n; x++) {
    zeros = zeros + Math.floor(n / 5 ** x);
  }
  return zeros;
}

projects · about · cv · home