desislava_topuzakova

04. Sum of Two Numbers

Nov 7th, 2020
2,389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. start_number = int(input())
  2. end_number = int(input())
  3. magic_number = int(input())
  4. count = 0 #брой на комбинациите
  5. #first -> [start_number до end_number]
  6. #second -> [start_number до end_number]
  7. is_found = False
  8. #всички комбинации между двете числа
  9. for first in range(start_number, end_number + 1):
  10.   for second in range(start_number, end_number + 1):
  11.     count += 1
  12.     if first + second == magic_number:
  13.       is_found = True
  14.       print(f"Combination N:{count} ({first} + {second} = {magic_number})")
  15.       break
  16.   if is_found:
  17.     break
  18.  
  19. if not is_found:
  20.   print(f"{count} combinations - neither equals {magic_number}")
Advertisement
Add Comment
Please, Sign In to add comment