# NOT RUN {
## Primes up to a thousand
primeSieve(1000)
## Primes between 42 and 1729
primeSieve(42, 1729)
## Equivalent to
primeSieve(1729, 42)
## Primes up to one hundred million in no time
system.time(primeSieve(10^8))
options(scipen = 50)
## Quickly generate large primes over small interval
system.time(myPs <- primeSieve(10^13+10^5, 10^13))
## Object created is small
object.size(myPs)
## Different classes when bound2 is provided
class(primeSieve(10^4))
class(primeSieve(1, 10^4))
all.equal(primeSieve(1,10^4), primeSieve(10^4))
## Compared to generating all primes up to the
## upper bound and subsetting (see below)
system.time(bound2_used <- primeSieve(10^9, 10^9+10^3))
object.size(bound2_used)
# }
# NOT RUN {
## Takes a decent amount of time
system.time(bound2_notused <- primeSieve(1000001000))
system.time(bound2_notused[bound2_notused >= 10^9])
## Creates large object
object.size(bound2_notused)
all.equal(bound2_notused[bound2_notused >= 10^9], bound2_used)
# }
Run the code above in your browser using DataLab