solved problem 13 in php