Elementary Number Theory in C#