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?
int limit = 0; int zahl = 1; int zaehler; int teiler; int zahl2; while (limit<10001) { if (zahl == 1){ System.out.println(""); } else { teiler = 0; for (zaehler = 1; zaehler <= zahl; zaehler++){ zahl2 = zahl % zaehler; if(zahl2 == 0){ teiler++; } } if (teiler == 2){ System.out.println(zahl); limit++; } } zahl++; }
Lösung: 104743