Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- first_num = int(input())
- final_num = int(input())
- magic_num = int(input())
- combinations = 0
- is_found = False
- for i in range(first_num, final_num + 1):
- for j in range(first_num, final_num + 1):
- combinations += 1
- if i + j == magic_num:
- print(f'Combination N:{combinations} ({i} + {j} = {magic_num})')
- is_found = True
- break
- if is_found:
- break
- if not is_found:
- print(f'{combinations} combinations - neither equals {magic_num}')
- Или:
- first_num = int(input())
- final_num = int(input())
- magic_num = int(input())
- combinations = 0
- for i in range(first_num, final_num + 1):
- for j in range(first_num, final_num + 1):
- combinations += 1
- if i + j == magic_num:
- print(f'Combination N:{combinations} ({i} + {j} = {magic_num})')
- exit(0)
- print(f'{combinations} combinations - neither equals {magic_num}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement