Пример #1
0
func main() {
	var factmap [10]uint64
	var total uint64
	for i := uint64(1); i < 10; i++ {
		factmap[i] = euler.Factorial(i)
	}
	for i := uint64(3); i < 10000000; i++ {
		if i == sum(apply(euler.Factorial, euler.NtoD(i))) {
			total += i
		}
	}
	fmt.Printf("32 %d\n", total)
}
Пример #2
0
func main() {
	var largest uint64
	digits := []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9}
	for i := uint64(1); i <= 9; i++ {
		numperms := euler.Factorial(i)
		for j := uint64(0); j < numperms; j++ {
			dn := euler.NthPerm(j, digits[:i])
			n := euler.DtoN(dn)
			if euler.IsPrime(n) && pandigital(n) {
				if n > largest {
					largest = n
				}
			}
		}
	}
	fmt.Printf("41 %d\n", largest)
}
Пример #3
0
func main() {
	var sum uint64
	digits := euler.NtoD(9876543210)
	firstprimes := []uint64{2, 3, 5, 7, 11, 13, 17}
	numperms := euler.Factorial(uint64(len(digits)))
search:
	for j := uint64(0); j < numperms; j++ {
		d := euler.NthPerm(j, digits)
		for i := range firstprimes {
			if euler.DtoN(d[i+1:i+4])%firstprimes[i] != 0 {
				continue search
			}
		}
		sum += euler.DtoN(d)
	}
	fmt.Printf("43 %d\n", sum)
}
Пример #4
0
func main() {
	var total uint64
	nf := euler.Factorial(9)
	uniq := make(map[uint64]bool)
	for i := uint64(0); i < nf; i++ {
		p := euler.NthPerm(i, []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9})
		for j := 1; j < 5; j++ {
			a, b, c := euler.DtoN(p[:j]), euler.DtoN(p[j:5]), euler.DtoN(p[5:])
			if a*b == c {
				uniq[c] = true
			}
		}
	}
	for i := range uniq {
		total += i
	}
	fmt.Printf("32 %d\n", total)
}