fork download
  1. def sumnum(n):
  2. lst = []
  3. x = 1
  4.  
  5. if n == 0: return [0]
  6. if n < 0: raise ValueError('Please n >= 0 number')
  7. while True:
  8. if n == sum([int(i) for i in str(x)]):
  9. if len(lst) < 5: lst.append(x)
  10. else: return lst
  11. x += 1
  12.  
  13. print(sumnum(12))
Success #stdin #stdout 0.02s 27712KB
stdin
Standard input is empty
stdout
[39, 48, 57, 66, 75]