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.1.0.50 tracks/r/exercises/sieve/example.R
trackler-2.1.0.49 tracks/r/exercises/sieve/example.R
trackler-2.1.0.48 tracks/r/exercises/sieve/example.R
trackler-2.1.0.47 tracks/r/exercises/sieve/example.R
trackler-2.1.0.46 tracks/r/exercises/sieve/example.R
trackler-2.1.0.45 tracks/r/exercises/sieve/example.R
trackler-2.1.0.44 tracks/r/exercises/sieve/example.R
trackler-2.1.0.43 tracks/r/exercises/sieve/example.R
trackler-2.1.0.42 tracks/r/exercises/sieve/example.R
trackler-2.1.0.41 tracks/r/exercises/sieve/example.R
trackler-2.1.0.40 tracks/r/exercises/sieve/example.R
trackler-2.1.0.39 tracks/r/exercises/sieve/example.R
trackler-2.1.0.38 tracks/r/exercises/sieve/example.R
trackler-2.1.0.37 tracks/r/exercises/sieve/example.R
trackler-2.1.0.36 tracks/r/exercises/sieve/example.R
trackler-2.1.0.34 tracks/r/exercises/sieve/example.R
trackler-2.1.0.33 tracks/r/exercises/sieve/example.R
trackler-2.1.0.32 tracks/r/exercises/sieve/example.R
trackler-2.1.0.31 tracks/r/exercises/sieve/example.R
trackler-2.1.0.30 tracks/r/exercises/sieve/example.R