func Problem_21() int { amicables := make([]uint64, 0) for i := 1; i < 10000; i++ { if x := helpers.IsAmicable(i); x != 0 && x < 10000 { amicables = helpers.AppendUnique(amicables, uint64(x), uint64(i)) } } sum := 0 for _, a := range amicables { sum += int(a) } fmt.Printf("The sum of all Amicable Numbers under 10,000 is %d\n", sum) return sum }
func Problem_32() int { pandigitals := make([]uint64, 0) for i := 1000; i < 10000; i++ { factors := helpers.Factorise(uint64(i), true) for _, f := range factors { intF := int(f) multiplicand := strconv.Itoa(i / intF) multiplier := strconv.Itoa(intF) product := strconv.Itoa(i) test := multiplicand + multiplier + product if len(test) == 9 && helpers.IsPandigital(test) { pandigitals = helpers.AppendUnique(pandigitals, uint64(i)) } } } sum := 0 for _, i := range pandigitals { sum += int(i) } fmt.Printf("Sum of all products whose multiplicand/multiplier/product "+ "identity is 1-9 pandigital is %d\n", sum) return sum }