fork(1) download
  1. import itertools as it
  2.  
  3. start = 100
  4. numbersCount = 3
  5. step = 10
  6. termsCount = 3
  7.  
  8. numbers = range(start, start + numbersCount * step, step)
  9. print(list(numbers))
  10. for terms in it.combinations_with_replacement(numbers, termsCount):
  11. print(sum(terms), '=', ' + '.join(map(str, terms)))
Success #stdin #stdout 0.01s 27712KB
stdin
Standard input is empty
stdout
[100, 110, 120]
300 = 100 + 100 + 100
310 = 100 + 100 + 110
320 = 100 + 100 + 120
320 = 100 + 110 + 110
330 = 100 + 110 + 120
340 = 100 + 120 + 120
330 = 110 + 110 + 110
340 = 110 + 110 + 120
350 = 110 + 120 + 120
360 = 120 + 120 + 120