solution to euler58.