General formalism solving linear recursion relations