python count prime solution


  • 0
    V

    '''
    class Solution(object):
    def countPrimes(self, n):
    count = 0
    for x in range(2, n):
    if self.issimple(x):
    count += 1
    return count
    def issimple(self, x):
    if x == 2:
    return True
    for y in range(2, x):
    if x % y == 0:
    return False
    if y * 2 > x:
    break
    return True
    '''


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.