My program is to find the number of perfect squares between any two given numbers(both inclusive)
# Enter your code here. Read input from STDIN. Print output to STDOUT
import math
t=int(raw_input())
for i in range(0,t):
count=0
s,e=raw_input().strip().split(' ')
s,e=[int(s),int(e)]
for j in range(s,e+1):
if math.sqrt(j)==math.floor(math.sqrt(j)):
count+=1
print count
When the input is for example:
3
59 999999922
9 999999966
12 999999988
The error that pops up is:
Traceback (most recent call last): File "solution.py", line 8, in for j in range(s,e+1): MemoryError
Why is this error coming up? and how can I solve it? Sorry I am new to this stackoverflow.