| MaxPrime/warnachinka | MaxPrime/disfavour | ||||
|---|---|---|---|---|---|
| n | 1 | N = int(input()) | n | 1 | n = int(input()) |
| 2 | 2 | ||||
| 3 | 3 | ||||
| n | 4 | def prime(x): | n | 4 | def isPrime(n): |
| 5 | if x % 2 == 0: | 5 | if n % 2 == 0: | ||
| 6 | return x == 2 | 6 | return n == 2 | ||
| 7 | y = 3 | 7 | d = 3 | ||
| 8 | while y * y <= x and x % y != 0: | 8 | while d * d <= n and n % d != 0: | ||
| 9 | y += 2 | 9 | d += 2 | ||
| 10 | return y ** 2 > x | 10 | return d * d > n | ||
| 11 | 11 | ||||
| 12 | 12 | ||||
| t | 13 | for i in range(N, 2, -1): | t | 13 | for i in range(n, 2, -1): |
| 14 | if prime(i): | 14 | if isPrime(i): | ||
| 15 | print(i) | 15 | print(i) | ||
| 16 | break | 16 | break | ||
| 17 | 17 | ||||
| Legends | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||