@ankit @kushagra.. Above example looks perfectly fine.
What i did in my comment on that que is ,
I wrote function f as a composition of 2 functions g:S→N and h:N→S.
This is fine..g and h are just counting functions so that are bijective.
But if f is onto but not one to one then one of these functions g and h must not be one to one..
So we can't write every f as composition of these 2 functions..Only those f that are bijections can be written like this.