Ruby: Squaring numbers and the rice checkerboard problem