示例#1
0
文件: c020.go 项目: moul/euler
func C020() (interface{}, error) {
	sum := 0

	factorial := utils.Factorial(100)
	for _, char := range factorial.String() {
		num, _ := strconv.Atoi(string(char))
		sum += num
	}

	return sum, nil
}
示例#2
0
文件: c034.go 项目: moul/euler
func C034() (interface{}, error) {
	total := 0
	for nb := 3; nb < 100000; nb++ {
		factSum := big.NewInt(0)

		for _, digit := range utils.NumberDigits(nb) {
			factSum = factSum.Add(factSum, utils.Factorial(digit))
		}
		if strconv.Itoa(nb) == factSum.String() {
			total += nb
		}
	}
	return total, nil
}