powered by
Unordered Pairing Function creating a new unique integer from two input integers.
ElegantPairingInt(int1, int2)
The function outputs a single non-negative integer that is uniquely associated with that unordered pair.
first integer to be paired.
second integer to be paired.
With two of non-negative integers x and y as an input, the pairing is computed as:
$$elegantPairing(x, y) = (x * y) + floor ((|x - y| - 1)^2) / 4)$$
The function is commutative. x and y have to be non-negative integers.
ElegantPairingVec
ElegantPairingInt(2, 3)
Run the code above in your browser using DataLab