Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # sumCombinations.py
- def sumCombinations(n, i, index=0, out=None):
- if not out:
- out=[0]*n
- if n == 0:
- print(out[:index])
- for j in range(i, n+1):
- out[index] = j
- sumCombinations(n-j, j, index+1, out)
- n = 7
- sumCombinations(n, 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement