Problem 47

Problem 47 - Project Euler
だめすぎる…10分はかかる…

limit <- 10^6
sieve <- logical(limit)
sieve[1] <- TRUE
crosslimit <- sqrt(limit)
counts <- numeric(limit)
for(i in 2:crosslimit){
  if(!sieve[i]){
    for(j in seq(i, limit, i)){
      sieve[j] <- TRUE
      counts[j] <- counts[j] + 1
    }
  }
}

i <- 1
while(1){
  if(all.equal(counts[i:(i+3)], rep(4, 4))==TRUE) break
  i <- i+1
  }
i