This is an implementation of the nimbers, which are technically a field over the non-negative ordinals, but in this case are restricted to the non-negative integers. Note that division by n is speedy for n < 16, about one second for n < 256, about a minute for n < 65535, and probably very, very, very slow for n >= 65535.