A linear-time algorithm for the orbit problem over cyclic groups