func main() { starttime := time.Now() fmt.Println("Hello, World", euler.Prime(10000)) fmt.Println("Elapsed time:", time.Since(starttime)) }
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)) }
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)) }
func main() { starttime := time.Now() total := int64(0) counter := 0 for i := int64(1); counter < factors; i++ { for euler.Prime(i)%2 == 0 || euler.Prime(i)%5 == 0 { i++ } if a(int(euler.Prime(i))) { counter++ total += euler.Prime(i) } } fmt.Println(total) fmt.Println("Elapsed time:", time.Since(starttime)) }
func main() { starttime := time.Now() fac := make([][2]int64, lid) for i := int64(1); i < lid+1; i++ { fac[i-1] = [2]int64{euler.Prime(i), 0} } var smallest big.Int smallest.SetString("9999999999999999", 10) for fac[0][1] = 0; fac[0][1] < top; fac[0][1]++ { for fac[1][1] = fac[0][1]; fac[1][1] >= 0; fac[1][1]-- { for fac[2][1] = fac[1][1]; fac[2][1] >= 0; fac[2][1]-- { for fac[3][1] = fac[2][1]; fac[3][1] >= 0; fac[3][1]-- { for fac[4][1] = fac[3][1]; fac[4][1] >= 0; fac[4][1]-- { for fac[5][1] = fac[4][1]; fac[5][1] >= 0; fac[5][1]-- { for fac[6][1] = fac[5][1]; fac[6][1] >= 0; fac[6][1]-- { for fac[7][1] = fac[6][1]; fac[7][1] >= 0; fac[7][1]-- { for fac[8][1] = fac[7][1]; fac[8][1] >= 0; fac[8][1]-- { for fac[9][1] = fac[8][1]; fac[9][1] >= 0; fac[9][1]-- { for fac[10][1] = fac[9][1]; fac[10][1] >= 0; fac[10][1]-- { for fac[11][1] = fac[10][1]; fac[11][1] >= 0; fac[11][1]-- { if solns(fac) > target && smallest.Cmp(evaluate(fac)) > 0 { smallest = *evaluate(fac) } } } } } } } } } } } } } fmt.Println(smallest.String()) fmt.Println("Elapsed time:", time.Since(starttime)) }