In this paper we give a simple and easy to implement method for the following problem. Given an operator L, compute an operator L~ of minimal order such that all solutions of L are derivatives of solutions of L~. If order(L~)=order(L) then we can also express each solution of L~, i.e. the anti-derivative of a solution y of L, as a linear combination of y and its derivatives. So in this case we have an easy way to integrate solutions y of L. The use of Ore rings makes our algorithm more general, so that it can be applied to the case of difference and q-difference equations as well. Note that this generalizes Gosper's algorithm in two ways, Gosper's algorithm treats only the case when L is a difference operator of order 1. Furthermore our method is also easier (less technical) than Gosper's algorithm. The technical steps are in the algorithm for computing rational solutions, we don't need to treat these steps because such algorithms are already given elsewhere. For the implementation see the file integrate_sols in the diffop package. Download the first version (ISSAC'97) of this paper dvi file or pdf file. Download the newer version (ITSF'99) of this paper: dvi file or pdf file.