Created
October 28, 2015 19:10
-
-
Save trys/910459822f04aec64aed to your computer and use it in GitHub Desktop.
Problem Twenty
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 factorial( n ) { | |
var product = bigInt(1); | |
for (var i = n; i > 0; i--) { | |
product = product.multiply( i ); | |
} | |
return product.toString(); | |
} | |
var number = factorial( 100 ), | |
result = 0; | |
for (var i = 0; i < number.length; i++) { | |
result += parseInt(number[ i ]); | |
} | |
document.write( result ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment