Created
June 10, 2020 19:29
-
-
Save sampletext32/0719d9a7ca2bcd2d083f913d52c8e61c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_prime(k): | |
d = 2 | |
while d * d <= k and k % d != 0: | |
d += 1 | |
return d * d > k | |
def pos_sum(matrix): | |
sum = 0 | |
for i in range(n): | |
for j in range(n): | |
if(matrix[i][j] > 0): | |
sum = sum + matrix[i][j] | |
return sum | |
n = int(input()) | |
m = [[13 + y + x*n for y in range(n)] for x in range(n)] | |
for i in range(n): | |
print(m[i]) | |
for i in range(n): | |
primes = 0 | |
for j in range(n): | |
if(is_prime(m[j][i])): | |
primes = primes + 1 | |
if (primes > 2): | |
print(i, ' столбец имеет более 2 простых числа') | |
sum = pos_sum(m) | |
print('Сумма положительных элементов: ', sum) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment