Project Euler 310 Nim Square