示例#1
0
func Problem_12() uint64 {
	fmt.Println("Finding first triangle number with > 500 factors")
	var i, current uint64 = 0, 0
	var factors []uint64

	for i = 1; ; i++ {
		current += i
		factors = helpers.Factorise(current, true)
		if len(factors) > 500 {
			fmt.Printf("Found %d with factors %d\n", current, factors)
			return current
		}
	}
	fmt.Printf("Not found\n")
	return uint64(0)
}
示例#2
0
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
}