Couldn't pass one test case

The 500,000th prime is 7,368,787.

so you should have to run the loop till 7,368,787.