MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / Sieve

Function Sieve

math/prime/sieve.go:16–23  ·  view source on GitHub ↗

Sieve Sieving the numbers that are not prime from the channel - basically removing them from the channels

(in <-chan int, out chan<- int, prime int)

Source from the content-addressed store, hash-verified

14
15// Sieve Sieving the numbers that are not prime from the channel - basically removing them from the channels
16func Sieve(in <-chan int, out chan<- int, prime int) {
17 for {
18 i := <-in
19 if i%prime != 0 {
20 out <- i
21 }
22 }
23}
24
25// Generate returns a int slice of prime numbers up to the limit
26func Generate(limit int) []int {

Callers 2

TestSieveFunction · 0.85
GenerateFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestSieveFunction · 0.68