Esempio n. 1
0
File: c020.go Progetto: 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
}
Esempio n. 2
0
File: c034.go Progetto: 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
}