Beispiel #1
0
func main() {
	starttime := time.Now()

	primes := make([][2]int64, 0)

	for i := int64(1); i <= euler.PrimePi(n); i++ {
		primes = append(primes, [2]int64{euler.Prime(i), 0})
	}

	total := 0

	var f func(level int)

	f = func(level int) {
		if level == len(primes) {
			total++
		} else {
			for primes[level][1] = 0; evaluateTrunc(primes, level+1) <= limit; primes[level][1]++ {
				f(level + 1)
			}
		}
	}

	f(0)

	fmt.Println(total)

	fmt.Println("Elapsed time:", time.Since(starttime))
}
Beispiel #2
0
func main() {
	starttime := time.Now()

	memo = make(map[int64]int)
	memo[1] = 1

	euler.PrimeCache(target)

	total := int64(0)

	for i := int64(1); i < euler.PrimePi(target); i++ {
		if length(euler.Prime(i)) == 25 {
			total += euler.Prime(i)
		}
	}

	fmt.Println(total)

	fmt.Println("Elapsed time:", time.Since(starttime))
}