solution of recursive 2