Sha256: bbb255a2f202c3dbfe7704de61eda8138e2f3b4e4915287175010d2c44fc77cf

Contents?: true

Size: 319 Bytes

Versions: 153

Compression:

Stored size: 319 Bytes

Contents

package sieve

const testVersion = 1

func Sieve(limit int) (primes []int) {
	c := make([]bool, limit)
	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

153 entries across 153 versions & 1 rubygems

Version Path
trackler-2.2.1.16 tracks/go/exercises/sieve/example.go
trackler-2.2.1.15 tracks/go/exercises/sieve/example.go
trackler-2.2.1.14 tracks/go/exercises/sieve/example.go
trackler-2.2.1.13 tracks/go/exercises/sieve/example.go
trackler-2.2.1.12 tracks/go/exercises/sieve/example.go
trackler-2.2.1.11 tracks/go/exercises/sieve/example.go
trackler-2.2.1.10 tracks/go/exercises/sieve/example.go
trackler-2.2.1.9 tracks/go/exercises/sieve/example.go
trackler-2.2.1.8 tracks/go/exercises/sieve/example.go
trackler-2.2.1.7 tracks/go/exercises/sieve/example.go
trackler-2.2.1.6 tracks/go/exercises/sieve/example.go
trackler-2.2.1.5 tracks/go/exercises/sieve/example.go
trackler-2.2.1.4 tracks/go/exercises/sieve/example.go
trackler-2.2.1.3 tracks/go/exercises/sieve/example.go
trackler-2.2.1.2 tracks/go/exercises/sieve/example.go
trackler-2.2.1.1 tracks/go/exercises/sieve/example.go
trackler-2.2.1.0 tracks/go/exercises/sieve/example.go
trackler-2.2.0.6 tracks/go/exercises/sieve/example.go
trackler-2.2.0.5 tracks/go/exercises/sieve/example.go
trackler-2.2.0.4 tracks/go/exercises/sieve/example.go