Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const input = [
- '10000'
- ];
- const print = this.print || console.log;
- const gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
- let n = +gets();
- let factorial = BigInt(1);
- for (let i = 1; i <= n; i++) {
- factorial *= BigInt(i);
- }
- let trailingZeroesCount = 0;
- let factorailStr = String(factorial);
- for (let i = factorailStr.length - 1; i >= 0; i--) {
- if (factorailStr[i] !== '0') {
- break;
- }
- trailingZeroesCount++;
- }
- print(trailingZeroesCount);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement