project euler solution magic