Reply
Thu 10 May, 2012 11:54 pm
Let f be a bijective function defined on the set of non-negative integers {0,1,2...}, then is it possible that f (1) = 0 ?
@DrewDad,
That maps 0 to -1, but the domain and range are non-negative integers.
@markr,
Actually, markr, the way you defined the function actually spoils the whole spirit of the question , because in your solution you directly use f ( 1) = 0 for defining the function , still it was a good approach.
@uvosky,
I thought it was a question about existence. Perhaps you prefer this:
f(x) = x xor 1
I think I should modify the question I asked , one can of course have a bijective function defined on non-negative set of integers such that f ( 1 ) = 0 the fact that such a bijection exists is trivial ,
the question is to find an explicit formula for such a bijective function ;
and this one to markr , which xor operation are you using ? can you please be more specific .
@uvosky,
bitwise exclusive or
Take the binary representation of the input and flip the least significant bit.