fork download
  1. import math
  2.  
  3. def isPrime(num): # Check if a given number is a prime
  4. # Using divison trial method
  5. square = math.sqrt(num) # The square root is the ceiling of divisible numbers
  6. divisor = 2 # Increments by one until it hits the square root
  7. if num == 1: return False
  8. while divisor <= square:
  9. if num % divisor == 0: # If theres no remainer than the number is not a prime
  10. return False
  11. else:
  12. divisor += 1 # Increment until reaching sqrt
  13. return True
  14. ## ----------------------------------------------------------------------- ##
  15. raw_prime_list = list()
  16. prime_list = list()
  17.  
  18. input_prime = int(raw_input())
  19.  
  20. while len(raw_prime_list) < input_prime:
  21. input = raw_input()
  22. raw_prime_list.append(input)
  23.  
  24. for entry in raw_prime_list:
  25. x, y = entry.split(' ')
  26. x = int(x)
  27. y = int(y)
  28.  
  29. while x <= y:
  30. if isPrime(x):
  31. print(x)
  32. x += 1
  33. print('\n')
  34.  
Success #stdin #stdout 0.02s 4712KB
stdin
2
1 10
3 5
stdout
2
3
5
7


3
5