bl00dt3ars

06. Sum And Product

Nov 21st, 2020 (edited)
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. n = int(input())
  2. is_true = False
  3.  
  4. for a in range(1, 9):
  5.     if is_true:
  6.         break
  7.     for b in range(9, a, - 1):
  8.         if is_true:
  9.             break
  10.         for c in range(0, 9):
  11.             if is_true:
  12.                 break
  13.             for d in range(9, c, - 1):
  14.                 current_sum1 = a + b + c + d
  15.                 current_sum2 = a * b * c * d
  16.                 if current_sum1 == current_sum2 and n % 10 == 5:
  17.                     print(f"{a}{b}{c}{d}")
  18.                     is_true = True
  19.                     break
  20.                 elif current_sum2 // current_sum1 == 3 and n % 3 == 0:
  21.                     print(f"{d}{c}{b}{a}")
  22.                     is_true = True
  23.                     break
  24.  
  25. if not is_true:
  26.     print("Nothing found")
Add Comment
Please, Sign In to add comment