Я думаю, что это аккуратное предложение:
import math
def squarit(n: int):
size = int(math.floor(math.sqrt(n)))
ans = [n//size]*size
for i in range(n-n//size*size):
ans[i] += 1
return size, ans
for i in range(4, 25):
print(f'{i}: {squarit(i)}')
Результат:
4: (2, [2, 2])
5: (2, [3, 2])
6: (2, [3, 3])
7: (2, [4, 3])
8: (2, [4, 4])
9: (3, [3, 3, 3])
10: (3, [4, 3, 3])
11: (3, [4, 4, 3])
12: (3, [4, 4, 4])
13: (3, [5, 4, 4])
14: (3, [5, 5, 4])
15: (3, [5, 5, 5])
16: (4, [4, 4, 4, 4])
17: (4, [5, 4, 4, 4])
18: (4, [5, 5, 4, 4])
19: (4, [5, 5, 5, 4])
20: (4, [5, 5, 5, 5])
21: (4, [6, 5, 5, 5])
22: (4, [6, 6, 5, 5])
23: (4, [6, 6, 6, 5])
24: (4, [6, 6, 6, 6])