Advertisement
GeorgiLukanov87

sum_n_product

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