Skip to content

Instantly share code, notes, and snippets.

@trys
Created October 28, 2015 19:10
Show Gist options
  • Save trys/910459822f04aec64aed to your computer and use it in GitHub Desktop.
Save trys/910459822f04aec64aed to your computer and use it in GitHub Desktop.
Problem Twenty
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