3 ms·
I asked a similar question for R about a year ago, and saw an interesting way to do it, taking advantage of the math. http://stackoverflow.com/questions/1162386
by christopheraden 13y ago
I asked a similar question for R about a year ago, and saw an interesting way to do it, taking advantage of the math.
http://stackoverflow.com/questions/11623865/faster-modulo-or-equality-checking-in-r-or-good-ways-to-vectorize http://stackoverflow.com/questions/11623865/faster-modulo-or...
- minimaxir 13y agoFun fact: in R, sum(1:1E07) will throw a warning; you have to use sum(as.numeric(1:1E07)) instead, which will indeed give the correct answer.