Sha256: 507b9d45bd1a468ea2e714e4006fe12f71f212ce6c4a824083d305f4cad46be7

Contents?: true

Size: 269 Bytes

Versions: 135

Compression:

Stored size: 269 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

135 entries across 135 versions & 1 rubygems

Version Path
trackler-2.0.8.24 tracks/r/exercises/sieve/example.R
trackler-2.0.8.23 tracks/r/exercises/sieve/example.R
trackler-2.0.8.22 tracks/r/exercises/sieve/example.R
trackler-2.0.8.21 tracks/r/exercises/sieve/example.R
trackler-2.0.8.20 tracks/r/exercises/sieve/example.R
trackler-2.0.8.19 tracks/r/exercises/sieve/example.R
trackler-2.0.8.18 tracks/r/exercises/sieve/example.R
trackler-2.0.8.17 tracks/r/exercises/sieve/example.R
trackler-2.0.8.16 tracks/r/exercises/sieve/example.R
trackler-2.0.8.15 tracks/r/exercises/sieve/example.R
trackler-2.0.8.14 tracks/r/exercises/sieve/example.R
trackler-2.0.8.13 tracks/r/exercises/sieve/example.R
trackler-2.0.8.12 tracks/r/exercises/sieve/example.R
trackler-2.0.8.11 tracks/r/exercises/sieve/example.R
trackler-2.0.8.10 tracks/r/exercises/sieve/example.R
trackler-2.0.8.9 tracks/r/exercises/sieve/example.R
trackler-2.0.8.8 tracks/r/exercises/sieve/example.R
trackler-2.0.8.7 tracks/r/exercises/sieve/example.R
trackler-2.0.8.6 tracks/r/exercises/sieve/example.R
trackler-2.0.8.5 tracks/r/exercises/sieve/example.R