title: “leetcode-204 Count Primes 质数计数”
更多解法: https://zszdata.com/2019/03/09/count-primes/
3种解法输出都对,但是前两种超时。
Count Primes
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.
Solution:
1:
class Solution:
def countPrimes(self, n: int) -> int:
count = 0
for i in range(2,n):
for j in range(2,i