Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # n = int(input())
- # is_valid = False # True
- # for a in range(1, 10):
- # for b in range(9, a - 1, -1):
- # for c in range(0, 10):
- # for d in range(9, c - 1, -1):
- # sum = a + b + c + d
- # product = a * b * c * d
- # if sum == product and n % 10 == 5:
- # is_valid = True
- # print(f'{a}{b}{c}{d}')
- # break
- # elif product // sum == 3 and n % 3 == 0:
- # is_valid = True
- # print(f'{d}{c}{b}{a}')
- # break
- # if is_valid:
- # break
- # if is_valid:
- # break
- # if is_valid:
- # break
- # if not is_valid:
- # print('Nothing found')
- n = int(input())
- is_valid = False # True
- for a in range(1, 10):
- for b in range(9, a - 1, -1):
- for c in range(0, 10):
- for d in range(9, c - 1, -1):
- sum = a + b + c + d
- product = a * b * c * d
- if sum == product and n % 10 == 5:
- is_valid = True
- print(f'{a}{b}{c}{d}')
- elif product // sum == 3 and n % 3 == 0:
- is_valid = True
- print(f'{d}{c}{b}{a}')
- if is_valid:
- exit()
- if not is_valid:
- print('Nothing found')
Advertisement
Add Comment
Please, Sign In to add comment