title: to calculate one million prime numbers
body: <p>I have got one question to print one million prime numbers . I have written a java program for that .. It's currently taking 1.5 mins approx to calculate it .. I think my solution is not that efficient. I have used the below algo:</p>
  
  <ul>
  <li>Adding 1 2 3 to the prime list initially </li>
  <li>Calculating the last digit of the number to be checked </li>
  <li>Checking if the digit is 0 , 2 or 4 or 6 or 8 then skipping the number</li>
  <li>else calculating the square root of the number .. </li>
  <li>Trying to Divide the number starting from 2 till the square root of the number </li>
  <li>if number is divisible then skipping the number else adding it to the prime list </li>
  </ul>
  
  <p>I have read several other solutions as well , but I didn't find a good answer. Please suggest ideally what should be approx minimum time to calculate this and what changes are required to make the algorithm more efficient.</p>