solved problem 2 both recursive and not