• + 0 comments

    Here is my Python solution! The highest and lowest variables are the highest and lowest square root that are between a and b. If the lowest is greater than b, we know that there are no perfect squares. Otherwise, it is simply the difference between the highest and lowest plus 1.

    def squares(a, b):
        highest = math.floor(math.sqrt(b))
        lowest = math.ceil(math.sqrt(a))
        print(lowest, highest)
        if lowest > b:
            return 0
        return highest - lowest + 1