Solved problem 4

C# solution for problem 4