Return all prime numbers smaller than M

后端 未结 9 2140
梦谈多话
梦谈多话 2021-01-02 14:46

Given an integer M. return all prime numbers smaller than M.

Give a algorithm as good as you can. Need to consider time and space complexity.

9条回答
  •  爱一瞬间的悲伤
    2021-01-02 15:37

    π(n) count the primes less than or equal to n. Pafnuty Chebyshev has shown that if

    limn→∞ π(n)/(n/ln(n))

    exists, it is 1. There are a lot of values that are approximately equal to π(n) actually, as shown in the table.

    enter image description here

    It gives right number of prime number for this number format.I hope this will be helpful.

提交回复
热议问题