Math problems, C++ and C# programming help