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.78 tracks/go/exercises/sieve/example.go
trackler-2.2.1.77 tracks/go/exercises/sieve/example.go
trackler-2.2.1.76 tracks/go/exercises/sieve/example.go
trackler-2.2.1.75 tracks/go/exercises/sieve/example.go
trackler-2.2.1.74 tracks/go/exercises/sieve/example.go
trackler-2.2.1.73 tracks/go/exercises/sieve/example.go
trackler-2.2.1.72 tracks/go/exercises/sieve/example.go
trackler-2.2.1.71 tracks/go/exercises/sieve/example.go
trackler-2.2.1.70 tracks/go/exercises/sieve/example.go
trackler-2.2.1.69 tracks/go/exercises/sieve/example.go
trackler-2.2.1.68 tracks/go/exercises/sieve/example.go