tweak Xmath.factorial to make accumulator function private