desislava_topuzakova

Untitled

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