title: Find position of prime number
body: <p>I need to do the reverse of finding the Nth prime, i.e. Given a prime number, I need to find its position in</p>
  
  <pre><code>2, 3, 5, 7...
  </code></pre>
  
  <p>The prime number can be large, in the order of <code>10^7</code>. Also, there are a lot of them.</p>
  
  <p>I have an index of pre-calculated primes which can be binary-searched, but I also have a space limit of 50k! Can sieve be done? Or any another fast way?</p>
  
  <p><strong>EDIT</strong>:
  Thanks a lot for all the brilliant answers, I wasn't expecting them! I hope they are useful to others looking for the same.</p>