Count the number of prime numbers less than a non-negative number, n.
Example:
Input: 10 Output: 4 Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7.
https://leetcode.com/explore/featured/card/top-interview-questions-easy/102/math/744/
一开始这么搞,有问题,会超时。主要原因是第一层迭代之后没有有效地过滤调不应该判断的值。比如说4,当迭代到4的时候,其实在2迭代的时候已经把4的所有值迭代过了,不需要再去判断它。同时还要注意括号内乘积的问题,修改内层循环的判断条件为 start*point<n即可。
AC代码: