Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- num = int(input())
- is_break = False
- for i in range(1, 9):
- for j in range(9, i, -1):
- for k in range(9):
- for l in range(9, k, -1):
- if (i + j + k + l) == i * j * k * l and num % 10 == 5:
- print(f"{i}{j}{k}{l}")
- is_break = True
- exit()
- if i * j * k * l // (i + j + k + l) == 3 and num % 3 == 0:
- print(f"{l}{k}{j}{i}")
- is_break = True
- exit()
- if not is_break:
- print("Nothing found")
- РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР:
- num = int(input())
- is_break = False
- for i in range(1, 9):
- for j in range(9, i, -1):
- for k in range(9):
- for l in range(9, k, -1):
- if (i + j + k + l) == i * j * k * l and num % 10 == 5 \
- or i * j * k * l // (i + j + k + l) == 3 and num % 3 == 0:
- print(f"{i}{j}{k}{l}" if (i + j + k + l) == i * j * k * l else f"{l}{k}{j}{i}")
- is_break = True
- exit()
- if not is_break:
- print("Nothing found")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement