Solved problem 5

C# solution for problem 5