Add function for generating Z_n
Fix bug in cyclic function