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.119 tracks/go/exercises/sieve/example.go
trackler-2.2.1.118 tracks/go/exercises/sieve/example.go
trackler-2.2.1.117 tracks/go/exercises/sieve/example.go
trackler-2.2.1.116 tracks/go/exercises/sieve/example.go
trackler-2.2.1.115 tracks/go/exercises/sieve/example.go
trackler-2.2.1.114 tracks/go/exercises/sieve/example.go
trackler-2.2.1.113 tracks/go/exercises/sieve/example.go
trackler-2.2.1.111 tracks/go/exercises/sieve/example.go
trackler-2.2.1.110 tracks/go/exercises/sieve/example.go
trackler-2.2.1.109 tracks/go/exercises/sieve/example.go
trackler-2.2.1.108 tracks/go/exercises/sieve/example.go
trackler-2.2.1.107 tracks/go/exercises/sieve/example.go
trackler-2.2.1.106 tracks/go/exercises/sieve/example.go
trackler-2.2.1.105 tracks/go/exercises/sieve/example.go
trackler-2.2.1.104 tracks/go/exercises/sieve/example.go
trackler-2.2.1.103 tracks/go/exercises/sieve/example.go
trackler-2.2.1.102 tracks/go/exercises/sieve/example.go
trackler-2.2.1.101 tracks/go/exercises/sieve/example.go
trackler-2.2.1.100 tracks/go/exercises/sieve/example.go
trackler-2.2.1.99 tracks/go/exercises/sieve/example.go