1
$\begingroup$

Let's say I have $k$ integers in the range of $[1,m]$ that I should like to represent as a single integer, such that no two selections of $k$ integers that differ in at least one yield the same result and in a way that I can reconstruct - if necessary - each from the final result.

I know that for $k = 2$ and two integers $a,b$, we could:

$n:= (m+1)a + b$

and then

$b \equiv n \pmod{m+1}$

$a = \lfloor\frac{n}{m+1}\rfloor$

How can I generalise this to arbitrary $k$? Do I just continue the pattern, i.e.

$nn:= (m+3)((m+1)a + b) + c$

with

$ c \equiv nn \pmod{m+3}$

$n := \lfloor\frac{nn}{m+3}\rfloor$

$b \equiv n \pmod{m+1}$

$a = \lfloor\frac{n}{m+1}\rfloor$

etc. or ..?

$\endgroup$

1 Answer 1

2
$\begingroup$

Continue your solution for $k=2$ in this manner: $$n_1+(m+1)n_2 + (m+1)^2n_3\cdots(m+1)^{k-1}n_k$$

$\endgroup$
2
  • 3
    $\begingroup$ Why not point out that this is just thinking about the $k$ numbers as the digits in a base $m+1$ representation? Since $0$ isn't admissible you can in fact do this in base $m$. $\endgroup$ Jan 22, 2016 at 14:20
  • $\begingroup$ @EthanBolker That didn't occur to me until after I posted, and I thought I'd give someone else a chance to make that observation. $\endgroup$
    – Logophobic
    Jan 22, 2016 at 14:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .