Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Terrance Blount
- A function that returns the count of prime numbers that exist ep to and including a giving number.
- '''
- def count_primes(num):
- primes = [2]
- x = 3
- if num < 2: # for the case of num = 0 or 1
- return 0
- while x <= num:
- for y in range(3,x,2): # test all odd factors up to x-1
- if x%y == 0:
- x += 2
- break
- else:
- primes.append(x)
- x += 2
- print(primes)
- return len(primes)
- print(count_primes(25))
Add Comment
Please, Sign In to add comment