how can I define my own list in which I have all primes less than x?
Asked
Active
Viewed 1,592 times
2
1 Answers
4
Prime @ Range @ PrimePi @ x. See e.g. this question What is so special about Prime? to get an idea about possible limitations of this approach.
Application of what is being said:
primeInf[x_] := Prime @ Range @ PrimePi @ x
primeInf@20
{2, 3, 5, 7, 11, 13, 17, 19}
Prime @ Range @ PrimePi @ x. See e.g. this question What is so special about Prime? to get an idea about possible limitations of this approach. – Artes May 07 '14 at 17:21Cases[Range@x, _?PrimeQ]But Artes version is much faster :) – Öskå May 07 '14 at 17:25NextPrimefunction see e.g. Why does iterating Prime in reverse order require much more time? for completing the method above. – Artes May 07 '14 at 17:28