def isPrime(n):
if n < 2: return False
if n == 2 or n == 3: return True
if n % 2 == 0: return False
for i in range(3, int(n**0.5) + 1, 2):
if n % i == 0: return False
return True
j, k = 0, 0
for i in range(int(input('n: ')) + 1):
if isPrime(i):
j +=1; k += 1; print('%7d' % i, end = '')
if j == 10: print(); j = 0
if j: print()
print(k, 'primes'); input()
def is_prime(a):
if a % 2 == 0:
return a == 2
d = 3
while d * d <= a and a % d != 0:
d += 2
return d * d > a
не проверял