Sha256: 3eb04b06388004d4b70e86b5f8c0b50fc4c9cf88e2b924ba33087fbee3ee13c5

Contents?: true

Size: 302 Bytes

Versions: 111

Compression:

Stored size: 302 Bytes

Contents

package sieve

func Sieve(limit int) (primes []int) {
	c := make([]bool, limit+1)
	for p := 2; p <= limit; {
		for i := p + p; i <= limit; i += p {
			c[i] = true
		}
		for p++; p <= limit && c[p]; p++ {
		}
	}
	for i := 2; i <= limit; i++ {
		if !c[i] {
			primes = append(primes, i)
		}
	}
	return
}

Version data entries

111 entries across 111 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/go/exercises/sieve/example.go
trackler-2.2.1.138 tracks/go/exercises/sieve/example.go
trackler-2.2.1.137 tracks/go/exercises/sieve/example.go
trackler-2.2.1.136 tracks/go/exercises/sieve/example.go
trackler-2.2.1.135 tracks/go/exercises/sieve/example.go
trackler-2.2.1.134 tracks/go/exercises/sieve/example.go
trackler-2.2.1.133 tracks/go/exercises/sieve/example.go
trackler-2.2.1.132 tracks/go/exercises/sieve/example.go
trackler-2.2.1.131 tracks/go/exercises/sieve/example.go
trackler-2.2.1.130 tracks/go/exercises/sieve/example.go
trackler-2.2.1.129 tracks/go/exercises/sieve/example.go
trackler-2.2.1.128 tracks/go/exercises/sieve/example.go
trackler-2.2.1.127 tracks/go/exercises/sieve/example.go
trackler-2.2.1.126 tracks/go/exercises/sieve/example.go
trackler-2.2.1.125 tracks/go/exercises/sieve/example.go
trackler-2.2.1.124 tracks/go/exercises/sieve/example.go
trackler-2.2.1.123 tracks/go/exercises/sieve/example.go
trackler-2.2.1.122 tracks/go/exercises/sieve/example.go
trackler-2.2.1.121 tracks/go/exercises/sieve/example.go
trackler-2.2.1.120 tracks/go/exercises/sieve/example.go