solved problem 31 with C#