solution to euler46.