Advertisement
nikolayneykov

Untitled

Nov 14th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const input = [
  2.   '10000'
  3. ];
  4.  
  5. const print = this.print || console.log;
  6. const gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
  7.  
  8. let n = +gets();
  9. let factorial = BigInt(1);
  10.  
  11. for (let i = 1; i <= n; i++) {
  12.   factorial *= BigInt(i);
  13. }
  14.  
  15. let trailingZeroesCount = 0;
  16.  
  17. let factorailStr = String(factorial);
  18. for (let i = factorailStr.length - 1; i >= 0; i--) {
  19.   if (factorailStr[i] !== '0') {
  20.     break;
  21.   }
  22.  
  23.   trailingZeroesCount++;
  24. }
  25.  
  26. print(trailingZeroesCount);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement