Project Euler 504 - Square on the Inside

Official link: https://projecteuler.net/problem=504