Formal and analytic solutions of differential and difference equations