Given Two integers L and R find the total number of distinct pairs (p,q)  between L and R ( both inclusive ) satisfying the given relationship. p! * q!=k^2 (a perfect square) where p,q,k is any integer and '!' denotes factorial.
Example 1:
Input: L = 0, R = 1
Output: 1
Explanation: 1 is the only perfect square
between 0 and 1; 
Example 2:
Input: L = 9, R = 25
Output: 3
Explanation: 9, 16 and 25 are the perfect 
squares between 9 and 25. 
Your Task:  
You don't need to read input or print anything. Complete the function countPerfectSquares() which takes L and R as an input parameter and returns the total number of perfect squares.
Expected Time Complexity: O(sqrt(N))
Expected Auxiliary Space: O(1)
Constraints:
0<= L <= R <=10^{18}

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3

class Solution:

    def countPerfectSquares (self, L, R):

        # code here 

Solutions:
import math

class Solution:

	def isPerfectSquare(self, x):
		if x >= 0:
			sr = math.floor(math.sqrt(x))
			return sr * sr == x
		return False

	def countPerfectSquares(self, L, R):
		if self.isPerfectSquare(L):
			return math.floor(math.sqrt(R)) - math.floor(math.sqrt(L)) + 1
		else:
			return math.floor(math.sqrt(R)) - math.floor(math.sqrt(L))