solved problem 17 in php