package xxx.xxx.xxx;
public class NthtPrime {
private void compute(int Nth) {
int count = 2;
int num = 3;
label:
while (true) {
System.out.println(count);
boolean isPrime = true;
for (int i = 2; i < num; i++) {
if (num % i == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
System.out.println("the "+count+"th prime is " + num);
if (count == Nth) {
break label;
}
count++;
}
num++;
}
// System.out.println("the "+count+"th prime is " + num);
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
NthtPrime nthtPrime = new NthtPrime();
nthtPrime.compute(10001);
}
}
public class NthtPrime {
private void compute(int Nth) {
int count = 2;
int num = 3;
label:
while (true) {
System.out.println(count);
boolean isPrime = true;
for (int i = 2; i < num; i++) {
if (num % i == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
System.out.println("the "+count+"th prime is " + num);
if (count == Nth) {
break label;
}
count++;
}
num++;
}
// System.out.println("the "+count+"th prime is " + num);
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
NthtPrime nthtPrime = new NthtPrime();
nthtPrime.compute(10001);
}
}