n | def is_prime(n): | n | def is_prime(num): |
| if n <= 1: | | if num <= 1: |
| return False | | return False |
n | if n <= 3: | n | if num <= 3: |
| return True | | return True |
n | if n % 2 == 0 or n % 3 == 0: | n | if num % 2 == 0 or num % 3 == 0: |
| return False | | return False |
| i = 5 | | i = 5 |
n | while i * i <= n: | n | while i * i <= num: |
| if n % i == 0 or n % (i + 2) == 0: | | if num % i == 0 or num % (i + 2) == 0: |
| return False | | return False |
| i += 6 | | i += 6 |
| return True | | return True |
| | | |
| def nonprime(n=0): | | def nonprime(n=0): |
n | current = n + 1 | n | num = n + 1 |
| while True: | | while True: |
t | if not is_prime(current): | t | if not is_prime(num): |
| yield current | | yield num |
| current += 1 | | num += 1 |