I am doing coding challenge named Integers: Recreation One in Codewars.
Challenge => Given two integers m, n (1 <= m <= n) we want to find all integers between m and n whose sum of squared divisors is itself a square.
def list_squared(m, n): lst = list() for num in range(m, n+1): total= 0 for i in range(1, num//2 +1): if num % i == 0: total += i**2 total += num**2 if (total**(1/2)) % 1 == 0: lst.append([num, total]) return lst
My code works for sample tests but when I try to submit it, it is giving me " Execution Timed Out " error. I think I have to make this more efficent but don't know how to do it. How can I make the code more efficent?