Sichanov

sum of two

Aug 13th, 2021
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. n1 = int(input())
  2. n2 = int(input())
  3. magic_num = int(input())
  4. combination = 0
  5.  
  6. for first in range(n1, n2 + 1):
  7.     for second in range(n1, n2 + 1):
  8.         combination += 1
  9.         if first + second == magic_num:
  10.             break
  11.     if first + second == magic_num:
  12.         break
  13.  
  14. if first + second != magic_num:
  15.     print(f'{combination} combinations - neither equals {magic_num}')
  16. else:
  17.     print(f'Combination N:{combination} ({n1} + {n2} = {magic_num})')
Advertisement
Add Comment
Please, Sign In to add comment