ZTransform[Piecewise[{{1, Mod[n, 2] == 0}, {2, Mod[n, 2] != 0}}], n, z]