nimsum = bitxor \\ after https://www.math.ucla.edu/~tom/NimProd.txt nimprod(x, y) = { my (F, i, t); if (x>y, [x,y]=[y,x]); \\ Now x<=y if (x==0, return (0), \\ Now x>=1 x==1, return (y), \\ Now x>=2 y==2, return (3), \\ Now y>=3 y==3, return (if (x==2, 1, 2)) \\ Now y>=4 ); F=4; \\ Fermat 2-power while (1, if (y==F, return (if (x