Project Euler/20: Difference between revisions
From charlesreid1
No edit summary |
m (Replacing charlesreid1.com:3000 with git.charlesreid1.com) |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
=Sum of Factorial Digits= | ==Sum of Factorial Digits== | ||
For this problem, you're asked to sum the digits of 100!. This is a very quick task using a library like BigInteger - the [[Go]] programming language also has the facilities built-in to handle numbers as large as 800!. | For this problem, you're asked to sum the digits of 100!. This is a very quick task using a Java library like BigInteger - the [[Go]] programming language also has the facilities built-in to handle numbers as large as 800!. | ||
https://charlesreid1.com | https://git.charlesreid1.com/charlesreid1/hello-world/src/master/go/factorial.go | ||
To do this in Java, you can use the | To do this in Java, you can use the BigInteger class, convert it to a String, and then turn the characters in the string into digits one at a time to sum them up. | ||
Code: https://git.charlesreid1.com/cs/euler/src/master/scratch/Round1_001-020/020/Quick.java | |||
==Flags== | |||
{{ProjectEulerFlag}} | {{ProjectEulerFlag}} | ||
Latest revision as of 03:47, 9 October 2019
Sum of Factorial Digits
For this problem, you're asked to sum the digits of 100!. This is a very quick task using a Java library like BigInteger - the Go programming language also has the facilities built-in to handle numbers as large as 800!.
https://git.charlesreid1.com/charlesreid1/hello-world/src/master/go/factorial.go
To do this in Java, you can use the BigInteger class, convert it to a String, and then turn the characters in the string into digits one at a time to sum them up.
Code: https://git.charlesreid1.com/cs/euler/src/master/scratch/Round1_001-020/020/Quick.java
Flags