Spocoman

13. Prime Pairs

Jan 2nd, 2022 (edited)
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. import math
  2.  
  3. first_start = int(input())
  4. second_start = int(input())
  5. first_diff = int(input())
  6. second_diff = int(input())
  7.  
  8. for i in range(first_start, first_start + first_diff + 1):
  9.     for j in range(second_start, second_start + second_diff + 1):
  10.         is_first_prime = True
  11.         is_second_prime = True
  12.  
  13.         for k in range(2, int(math.sqrt(i)) + 1):
  14.             if i % k == 0:
  15.                 is_first_prime = False
  16.                 break
  17.         for k in range(2, int(math.sqrt(j)) + 1):
  18.             if j % k == 0:
  19.                 is_second_prime = False
  20.                 break
  21.         if is_first_prime and is_second_prime:
  22.             print(f'{i}{j}')
  23.  
  24.  
Add Comment
Please, Sign In to add comment