Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def output(l):
- length = len(l)
- for i in range(length-1):
- print(l[i], end="+")
- print(l[-1])
- def decomposition(rest, previous=None, current=[]):
- if previous is None:
- previous = rest
- if rest == 0:
- output(current)
- else:
- max_summand = min(rest, previous)
- for i in range(max_summand, 0, -1):
- current.append(i)
- decomposition(rest - i, i, current)
- current.pop()
- number = int(input())
- decomposition(number)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement