changed mod to not be on the prototype of Number, which speeds things
up.  Tried to memoize mod, but with the current memoization
implementation it was slower