Let p be a fixed positive integer. Prove that the mapping f : \mathbb{Z} → \mathbb{Z} given by
f(n)={\left\{\begin{array}{l l}{n+p}&{{\mathrm{if}}}&{n{\mathrm{~is~divisible~by~}}p,}\\ {n}&{{\mathrm{if}}}&{n{\mathrm{~is~not~divisible~by~}}p,}\end{array}\right.}is a bijection, and determine f^{-1}.
Note from the definition of f that f(n) is divisible by p if and only if n is divisible by p. Thus if f(n_{1})=f(n_{2}) then either f(n_{1}) is divisible by p, in which case n_{1}=f(n_{1})-p=f(n_{2})-p=n_{2},\ \mathrm{or}\ \ f(n_{1}) is not divisible by p, in which case n_{1}=f(n_{1})=f(n_{2})=n_{2}. Hence f is an injection.
To show that f is also surjective, suppose that k\in\mathbb{Z}. If k is not divisible by p then f(k) = k; and if k is divisible by p then so is k – p whence f(k- p) = (k – p) + p = k. Hence f i s a surjection.
As for f^{-1}\colon\mathbb{Z}\to\mathbb{Z}, this is given by
f^{-1}(n)={\left\{\begin{array}{l l}{n}&{{\mathrm{if~}}n{\mathrm{~is~not~divisible~by~}}p;}\\ {n-p}&{{\mathrm{if~}}n{\mathrm{~is~divisible~by~}}p.}\end{array}\right.}