Solved problem 364 base case