Created
July 11, 2018 16:45
-
-
Save vitkarpov/9f6df2638a060a89dafabf5dc724ea7c to your computer and use it in GitHub Desktop.
Extra Long Factorial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mult(a, b) { | |
let carry = 0; | |
for (let i = 0; i < a.length || carry > 0; i++) { | |
if (i === a.length) { | |
a.push(0); | |
} | |
const curr = carry + a[i] * b; | |
a[i] = curr % 10; | |
carry = Math.floor(curr / 10); | |
} | |
} | |
// mult in loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment