def quadratic_residues(p):
 r = set()
 for i in range(((p // 2) + 1)):
  r.add(pow(i, 2, p))
 return sorted(list(r))

def quadratic_residues ( p ) : r = set ( ) for i in range ( ( ( p // 2 ) + 1 ) ) : r . add ( pow ( i , 2 , p ) ) return sorted ( list ( r ) )
returns the list of quadratic residues .