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.180 tracks/go/exercises/sieve/example.go
trackler-2.2.1.179 tracks/go/exercises/sieve/example.go
trackler-2.2.1.178 tracks/go/exercises/sieve/example.go
trackler-2.2.1.177 tracks/go/exercises/sieve/example.go
trackler-2.2.1.176 tracks/go/exercises/sieve/example.go
trackler-2.2.1.175 tracks/go/exercises/sieve/example.go
trackler-2.2.1.174 tracks/go/exercises/sieve/example.go
trackler-2.2.1.173 tracks/go/exercises/sieve/example.go
trackler-2.2.1.172 tracks/go/exercises/sieve/example.go
trackler-2.2.1.171 tracks/go/exercises/sieve/example.go
trackler-2.2.1.170 tracks/go/exercises/sieve/example.go
trackler-2.2.1.169 tracks/go/exercises/sieve/example.go
trackler-2.2.1.167 tracks/go/exercises/sieve/example.go
trackler-2.2.1.166 tracks/go/exercises/sieve/example.go
trackler-2.2.1.165 tracks/go/exercises/sieve/example.go
trackler-2.2.1.164 tracks/go/exercises/sieve/example.go
trackler-2.2.1.163 tracks/go/exercises/sieve/example.go
trackler-2.2.1.162 tracks/go/exercises/sieve/example.go
trackler-2.2.1.161 tracks/go/exercises/sieve/example.go
trackler-2.2.1.160 tracks/go/exercises/sieve/example.go