I need a C# implementation of the gamma function that produces correct exact answers at positive integer inputs. I took a look at MathNet.Numerics Meta.Numerics. In both cases, if you calculate something like gamma(5)-4!, evaluating the latter by integer arithmetic, you get an answer whose absolute value is approximately 10^-14, instead of the expected zero.
I could code in the integers as a special case. But that would lead to some strange behavior; for example, my gamma function might not be monotonically increasing for x>=2.
Is anyone aware of a library that will work?