Esempio n. 1
0
func Exercise21() uint64 {
	sum := uint64(0)
	for num := uint64(1); num < uint64(10000); num++ {
		factors := primes.AllFactors(num)
		factors = factors[0 : len(factors)-1] // shave off "self"
		dn := utils.AccumulateUint64(factors)
		if dn < uint64(10000) {
			if lookup[dn] == num {
				sum += num + dn
			}
			lookup[num] = dn
		}
	}
	return sum
}
Esempio n. 2
0
func collectabundant() { // []int {
	abundant := make([]uint64, 0, 28124)

	for i := uint64(2); i <= uint64(maxabundant); i++ {
		sel := false
		for _, a := range abundant {
			if i%a == 0 {
				abundant = append(abundant, i)
				sel = true
			}
		}
		if !sel {
			factors := primes.AllFactors(uint64(i))
			factors = factors[0 : len(factors)-1]
			sum := utils.AccumulateUint64(factors)
			if sum > uint64(i) {
				abundant = append(abundant, i)
			}
		}
	}
	fmt.Println(abundant)
}