# Problem 7

/ Published in: Java

Project Euler Question 7:

"By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.

What is the 10 001st prime number?"

Input: 10001

Output: 104743

`import java.math.*;    public class Prob7{      public static void main(String[] argsv){         int primenum = 0;         long prime = 1; // I know 1 isn't a prime, but this makes the code easier to write         int nth = new Integer(argsv[0]).intValue();         while(primenum < nth){            prime = nextPrime(prime);            primenum++;         }         System.out.println(prime);      }        private static long nextPrime(long n){         n++;         while(!isPrime(n)){            n++;         }         return n;      }       private static boolean isPrime(long n){         long limit = (long) Math.sqrt(n);         for(long i = 2; i <= limit; i++){            if(n % i == 0){               return false;            }         }         return true;      }   }`