py.user.next
ni = {} def partition(number): global ni answer = {(number,), } for x in range(1, number): for y in partition(number - x): answer.add(tuple(sorted((x, ) + y))) ni[number] = answer return answer print('К-во разделов числа:') for r in sorted(partition(5))[::-1]: print('\t' + ' + '.join(str(i) for i in r))