Fix the brute force approach by applying Sqrt