Mapping two integers to one, in a unique and deterministic way

前端 未结 19 2425
不知归路
不知归路 2020-11-22 09:35

Imagine two positive integers A and B. I want to combine these two into a single integer C.

There can be no other integers D and E which combine to C. So combining

19条回答
  •  轮回少年
    2020-11-22 10:02

    Let number a be the first, b the second. Let p be the a+1-th prime number, q be the b+1-th prime number

    Then, the result is pq, if a or 2pq if a>b. If a=b, let it be p^2.

提交回复
热议问题