Semigroups of maps and periodic difference equations