title: Encode a sequence of numbers as a single number -- use chinese remainder theorem
body: <p>I need to encode a sequence <code>S</code> of an arbitrary number of elements (but finite) with an whole number <code>K</code>, and be able to decode <code>K</code> in order to obtain back the initial sequence.</p>
  
  <p>I need to do it such that a computer be able to cope good with the number <code>K</code>.</p>
  
  <p>I did it so (in lisp):</p>
  
  <ul>
  <li><p>suppose that the sequence S has n elements e1, ... en</p></li>
  <li><p>generate first n prime numbers p1 ... pn</p></li>
  <li><p>write K = p1^e1 + p2 ^ e2 + ... + pn ^ en</p></li>
  </ul>
  
  <p>I tried this method. However, I get huge numbers.</p>
  
  <p>I know that it is possible to use the <code>chinese remainder theorem</code> to solve the problem, and the <code>K</code> obtained so is not that large.</p>
  
  <p>Somebody can help me to use this theorem such that I encode a sequence ?</p>
  
  <p>EDIT:</p>
  
  <p>I wish to see the algorithm of encoding using <code>ch r th</code> using a concrete simple example. I cannot understand the theoretical ideas from wikipedia and other web resources.</p>