Show that f : N → N, given by

Let x, m be any two odd natural numbers.
Then f(x) = f (m) ⇒ x + 1 = m + 1 ⇒ x = m Let x, m be any two even natural numbers.
Then f (x) = f (m) ⇒ x – 1 = m – 1 ⇒ x = m
is both the cases, f (x) = f(m) ⇒ x = m If x is even and m is odd, then x ≠ m Also f (x) is odd and f (m) is even. So, f (x) ≠ f(m) ∴ x ≠ m ⇒ f (x) ≠ f (m) ∴ f is one-to-one.
Now, let x be an arbitrary natural number. If x is an odd number, then there exists an even natural number (x + 1) such that f(x + 1) = x + 1–1 = x. If x is an even number, then there exists an odd natural number (x – 1) such that
Let x, m be any two odd natural numbers.
Then f(x) = f (m) ⇒ x + 1 = m + 1 ⇒ x = m Let x, m be any two even natural numbers.
Then f (x) = f (m) ⇒ x – 1 = m – 1 ⇒ x = m
is both the cases, f (x) = f(m) ⇒ x = m If x is even and m is odd, then x ≠ m Also f (x) is odd and f (m) is even. So, f (x) ≠ f(m) ∴ x ≠ m ⇒ f (x) ≠ f (m) ∴ f is one-to-one.
Now, let x be an arbitrary natural number. If x is an odd number, then there exists an even natural number (x + 1) such that f(x + 1) = x + 1–1 = x. If x is an even number, then there exists an odd natural number (x – 1) such that
f (x – 1) = (x – 1) + 1 = x
∴ every x ∈ N has its pre-image in N
∴ f : N → N is onto.
∴ f is one-to-one and onto.