Моисеев Дмитрий, 524 группа NonPrime 8871 | Андрей Спиваков, 524 группа NonPrime 8910 | ||||
---|---|---|---|---|---|
n | 1 | def is_nonprime(num): | n | 1 | def is_prime(num): |
2 | if num < 2: | 2 | if num < 2: | ||
n | 3 | return True | n | 3 | return False |
4 | for i in range(2, int(num ** 0.5) + 1): | 4 | for i in range(2, int(num ** 0.5) + 1): | ||
5 | if num % i == 0: | 5 | if num % i == 0: | ||
n | 6 | return True | n | 6 | return False |
7 | return False | 7 | return True | ||
8 | 8 | ||||
9 | def nonprime(n=0): | 9 | def nonprime(n=0): | ||
n | 10 | current = max(1, n + 1) | n | 10 | cur = max(1, n + 1) |
11 | while True: | 11 | while True: | ||
t | 12 | if is_nonprime(current): | t | 12 | if not is_prime(cur): |
13 | yield current | 13 | yield cur | ||
14 | current += 1 | 14 | cur += 1 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|