Last active
July 4, 2019 19:32
-
-
Save kirkins/c5c323a376dafd4920944563d9c21bc4 to your computer and use it in GitHub Desktop.
Euler Problem #20 in JS
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
// factorial | |
f = (n) => { | |
n = BigInt(n); | |
return (n>1) ? n * f(n-1n) : n; | |
} | |
// sum of digits in the number | |
s = (n) => { | |
return n.toString().split("") | |
.map(x => parseInt(x)) | |
.reduce((a, b) => a+b); | |
} | |
console.log(s(f(100))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment