Create unique number from 2 numbers

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


The sort of function you are looking for is often called a pairing function.

A standard example is the Cantor pairing function N×NN, given by:

You can find more information here:

Source : Link , Question Author : drizzt , Answer Author : Alex Kruckman

Leave a Comment