rows_N = int(input("Введите количество строк N (N>=1): "))
if rows_N >= 1:
column_K = int(input("Введите количество столбцов K (K>=3): "))
if column_K >= 3:
mas = [[0 for j in range(column_K)] for i in range(rows_N)]
k = 0
n = 0
for k in range(1, column_K + 1):
for n in range(1, rows_N + 1):
if k == 1:
x = 1
else:
x = int(1 / 2 * k * (n**2 - n) - n**2 + 2 * n)
mas[n - 1][k - 1] = x
for row in mas:
print(", ".join([f"{x:>4}" for x in row]))
Введите количество строк N (N>=1): 15
Введите количество столбцов K (K>=3): 10
1, 1, 1, 1, 1, 1, 1, 1, 1, 1
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
1, 3, 6, 9, 12, 15, 18, 21, 24, 27
1, 4, 10, 16, 22, 28, 34, 40, 46, 52
1, 5, 15, 25, 35, 45, 55, 65, 75, 85
1, 6, 21, 36, 51, 66, 81, 96, 111, 126
1, 7, 28, 49, 70, 91, 112, 133, 154, 175
1, 8, 36, 64, 92, 120, 148, 176, 204, 232
1, 9, 45, 81, 117, 153, 189, 225, 261, 297
1, 10, 55, 100, 145, 190, 235, 280, 325, 370
1, 11, 66, 121, 176, 231, 286, 341, 396, 451
1, 12, 78, 144, 210, 276, 342, 408, 474, 540
1, 13, 91, 169, 247, 325, 403, 481, 559, 637
1, 14, 105, 196, 287, 378, 469, 560, 651, 742
1, 15, 120, 225, 330, 435, 540, 645, 750, 855