Абдикашева Вилена Ринатовна, 411 группа NonPrime 10298 | Федченко Данил 307 NonPrime 10426 | ||||
---|---|---|---|---|---|
n | 1 | def nonprime(start=0): | n | 1 | def nonprime(n=0): |
2 | candidate = start + 1 | 2 | num = n + 1 | ||
3 | while True: | 3 | while True: | ||
n | 4 | if is_composite(candidate): | n | 4 | if not is_prime(num): |
5 | yield candidate | 5 | yield num | ||
6 | candidate += 1 | 6 | num += 1 | ||
7 | 7 | ||||
t | 8 | def is_composite(x): | t | 8 | def is_prime(num): |
9 | if x == 1: | 9 | if num == 1: | ||
10 | return True | ||||
11 | for divisor in range(2, int(x ** 0.5) + 1): | ||||
12 | if x % divisor == 0: | ||||
13 | return True | ||||
14 | return False | 10 | return False | ||
11 | for i in range(2, int(num ** 0.5) + 1): | ||||
12 | if num % i == 0: | ||||
13 | return False | ||||
14 | return True |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|