desislava_topuzakova

04. Sum of Two Numbers

Oct 21st, 2020
829
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. start_number = int(input())
  2. end_number = int(input())
  3. magic_number = int(input())
  4. counter = 0
  5. is_found_valid_combinations = False
  6. for first_number in range(start_number, end_number+1):
  7.     if is_found_valid_combinations:
  8.         break
  9.     for second_number in range(start_number, end_number+1):
  10.         counter += 1
  11.         if first_number + second_number == magic_number:
  12.             print(f"Combination N:{counter} ({first_number} + {second_number} = {magic_number})")
  13.             is_found_valid_combinations = True
  14.             break
  15. if not is_found_valid_combinations:
  16.     print(f"{counter} combinations - neither equals {magic_number}")
RAW Paste Data