Sha256: 172494d923f699ae3f5702e72a68dc52c6b5715a18d0bb47837b8cd41a61d199

Contents?: true

Size: 274 Bytes

Versions: 171

Compression:

Stored size: 274 Bytes

Contents

sieve <- function(limit) {
  if (limit < 2) {
    return(c())
  }
  nums <- rep(TRUE, limit)
  nums[1] <- FALSE
  for (i in 2:limit) {
    if (nums[i]) {
      div <- floor(limit / i)
      if (div > 1) {
        nums[i * 2:div] <- FALSE  
      }
    }
  }
  which(nums)
}

Version data entries

171 entries across 171 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/r/exercises/sieve/example.R
trackler-2.2.1.179 tracks/r/exercises/sieve/example.R
trackler-2.2.1.178 tracks/r/exercises/sieve/example.R
trackler-2.2.1.177 tracks/r/exercises/sieve/example.R
trackler-2.2.1.176 tracks/r/exercises/sieve/example.R
trackler-2.2.1.175 tracks/r/exercises/sieve/example.R
trackler-2.2.1.174 tracks/r/exercises/sieve/example.R
trackler-2.2.1.173 tracks/r/exercises/sieve/example.R
trackler-2.2.1.172 tracks/r/exercises/sieve/example.R
trackler-2.2.1.171 tracks/r/exercises/sieve/example.R
trackler-2.2.1.170 tracks/r/exercises/sieve/example.R
trackler-2.2.1.169 tracks/r/exercises/sieve/example.R
trackler-2.2.1.167 tracks/r/exercises/sieve/example.R
trackler-2.2.1.166 tracks/r/exercises/sieve/example.R
trackler-2.2.1.165 tracks/r/exercises/sieve/example.R
trackler-2.2.1.164 tracks/r/exercises/sieve/example.R
trackler-2.2.1.163 tracks/r/exercises/sieve/example.R
trackler-2.2.1.162 tracks/r/exercises/sieve/example.R
trackler-2.2.1.161 tracks/r/exercises/sieve/example.R
trackler-2.2.1.160 tracks/r/exercises/sieve/example.R