Tuesday, 6 May 2014

natural numbers - Function of two integers that has not repeated values




In order to implement a software I need a function f:N×NN such that:
(xxyy)f(x,y)f(x,y)



It's very easy to implement an algorithm that implements such a function, but I was not able to find an analytical representation of it.



coult you help me?


Answer



The usual "Cantor zig-zag" mapping can be defined as




(x,y)(x+y)(x+y+1)2+x



It has the (sometimes) nice property that it is surjective, that is, every natural number is the image of some pair, so nothing goes to waste.


No comments:

Post a Comment

real analysis - How to find limhrightarrow0fracsin(ha)h

How to find lim without lhopital rule? I know when I use lhopital I easy get $$ \lim_{h\rightarrow 0}...