title: How to calculate the index (lexicographical order) when the combination is given
body: <p>I know that there is an algorithm that permits, given a combination of number (no repetitions, no order), calculates the index of the lexicographic order.<br>
  It would be very useful for my application to speedup things...</p>
  
  <p>For example:  </p>
  
  <pre><code>combination(10, 5)  
  1 - 1 2 3 4 5  
  2 - 1 2 3 4 6  
  3 - 1 2 3 4 7  
  ....  
  251 - 5 7 8 9 10  
  252 - 6 7 8 9 10  
  </code></pre>
  
  <p>I need that the algorithm returns the index of the given combination.<br>
  es: <code>index( 2, 5, 7, 8, 10 )</code> --> index  </p>
  
  <p>EDIT: actually I'm using a java application that generates all combinations C(53, 5) and inserts them into a TreeMap.
  My idea is to create an array that contains all combinations (and related data) that I can index with this algorithm.<br>
  Everything is to speedup combination searching.
  However I tried some (not all) of your solutions and the algorithms that you proposed are slower that a get() from TreeMap.<br>
  If it helps: my needs are for a combination of 5 from 53 starting from 0 to 52.</p>
  
  <p>Thank you again to all :-)</p>