Advertisement
Guest User

Untitled

a guest
Dec 9th, 2017
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. from math import sqrt
  2.  
  3. def list_squared(m, n):
  4.     res = []
  5.     for x in range(m, n+1):
  6.         divisors = []
  7.         for q in range(1, int(sqrt(x))+1):
  8.             if x % q == 0:
  9.                 divisors.append(q**2)
  10.                 if x / q != q:
  11.                     divisors.append((x/q)**2)
  12.         if sqrt(sum(divisors)) == int(sqrt(sum(divisors))):
  13.             res.append([x, sum(divisors)])
  14.     return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement