Sichanov

sum of two numbers

Jul 10th, 2021
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. start = int(input())
  2. end = int(input())
  3. magic_number = int(input())
  4. combinations = 0
  5. magic_number_found = False
  6. for x in range(start, end + 1):
  7.     for y in range(start, end + 1):
  8.         combinations += 1
  9.         sum = x + y
  10.         if sum == magic_number:
  11.             print(f"Combination N:{combinations} ({x} + {y} = {magic_number})")
  12.             magic_number_found = True
  13.             break
  14.     if magic_number_found:
  15.         break
  16. if not magic_number_found:
  17.     print(f"{combinations} combinations - neither equals {magic_number}")
Advertisement
Add Comment
Please, Sign In to add comment