Teo_Yanchev

sum_of_2_numbers_while

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