Implemented final stage of gosper algorithm