Exemple #1
0
func E40() int {
	prod := 1
	for i := 0; i <= 6; i++ {
		prod *= d(utils.Pow(10, i))
	}
	return prod
}
Exemple #2
0
func E124() int {
	const upto = 100000
	primes := utils.Primes(upto)

	rad := make(TupleArray, upto+1)
	for i := 1; i <= upto; i++ {
		rad[i][0], rad[i][1] = i, i
	}

	for _, i := range primes {
		for k := 2; utils.Pow(i, k) <= upto && utils.Pow(i, k) > 0; k++ {
			for j := utils.Pow(i, k); j <= upto; j += utils.Pow(i, k) {
				rad[j][1] /= i
			}
		}
	}

	sort.Sort(rad)
	return rad[10000][0]
}
Exemple #3
0
func E32() (sum int) {

	products := make(map[int]bool)

	// i, j = number of digits in the multiplicand, multiplier
	// i + j + (i + j - 1) = 2*i + 2*j - 1 = 9 => i + j = 5
	for d := 1; d < 5; d++ {
		for i := utils.Pow(10, d-1); i < utils.Pow(10, d); i++ {
			for j := utils.Pow(10, 5-d-1); i <= j && j < utils.Pow(10, 5-d); j++ {
				if isPandigital(i, j, i*j) {
					products[i*j] = true
				}
			}
		}
	}

	for k, _ := range products {
		sum += k
	}

	return sum
}