Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

32 lines (24 sloc) 0.444 kb
package main
import (
"fmt"
"math/big"
)
func SumDigitsOf(number *big.Int) int {
digits := number.String()
sum := int(0)
for _, digit := range digits {
sum += int(digit - '0')
}
return sum
}
func Factorial(number int64) *big.Int {
factorial := big.NewInt(1)
for i := number; i >= 1; i-- {
factorial.Mul(factorial, big.NewInt(i))
}
return factorial
}
func main() {
fact := Factorial(100)
fmt.Println(SumDigitsOf(fact))
}
Jump to Line
Something went wrong with that request. Please try again.