package main import ( "fmt" "os" "strconv" "time" ) func main() { n, err := strconv.ParseInt(os.Args[1], 10, 64) if err != nil { panic(err) } t0 := time.Now() sieve := make([]bool, n) var found int64 var i int64 i = 2 found++ for i = 3; i < n; i += 2 { if !sieve[i] { found++ for j := i * i; j < n; j += 2 * i { sieve[j] = true } } } d := time.Since(t0) fmt.Println() fmt.Println(found, "primes found in", d) }