is there some way to create unique number from 2 positive integer numbers? Result must be unique even for these pairs: 2 and 30, 1 and 15, 4 and 60. In general, if I take 2 random numbers result must be unique(or with very high probability unique)
Thanks a lot
EDIT: calculation is for computer program,so computational complexity is important
Answer
The sort of function you are looking for is often called a pairing function.
A standard example is the Cantor pairing function N×N→N, given by:
π(a,b)=12(a+b)(a+b+1)+b.
You can find more information here: http://en.wikipedia.org/wiki/pairing_function
Attribution
Source : Link , Question Author : drizzt , Answer Author : Alex Kruckman