# Give an example of a function from n to n that is

Give an example of a function from N to N that is

a) one-to-one but not onto
b) onto but not one-to-one
c) both one and one-to-one (but different from the
identityfunction)
d) neither one-to-one nor onto

a) Let f : N--> N be a function defined as

f(n) =2n.
It is one to one because if f(n) =f(m) then 2n
=2m implies n = m.
But it is not onto since 3 has nopre image. That
is there exists no positive integer such that f(n)=3.
b) Let g : N--> N be a function defined as
g(n) = (n+1)/2 if n is odd
= n/2 if n is even.
g is not one to one since g(1) =(1+1)/2 =1 and
g(2) =2/2 =1, that is g(1) = g(2).
g is onto because for each n in Nwe have g(2n) =
2n/2 = n, that is 2n is the preimage of n.
c) Let h : N--> N be a function defined as
h(n) = n+1 if n isodd (in this case h(n) is
even)
= n-1 if n is even.(in this case h(n)
is odd).
Clearly h is not
identityfunction
Suppose h(n) =h(m).
If h(n) is odd then h(n) = n-1. Similarly h(m) =m-1.
Therforen-1 = m-1 and hence n=m.
If h(n) is even then h(n) = n+1. Similarly h(m)=m+1. Therfore
n+1 = m+1 and hence n=m.
So h is one to onefunction.
Let k be an element ofN.
If k is odd k+1 is even and h(k+1) =
k+1-1 = k(by definition)
If k is even k-1 is odd and h(k-1)
=k-1+1 = k, (by definition)
This shows h is onto.
Therefore h is abijective function.
d) Let g : N--> N be a function definedas
g(n) = (n+3)/2 if n is odd
= (n+2)/2 if n is even.
g is not one to onesince g(1) = (1+3)/2 =2 and
g(2) =(2+2)/2 =2, that is g(1) =g(2).
g is not onto since 1has no preimage. Because 1 =
g(-1) = g(0) and both 0 and -1 doesnot belong to N.