PrimzahlenFinden

Aus ProgrammingWiki

Wiki-Quelltext dieser Seite.

<language>Java</language>
<eval id="4c76bdbc4c38f">
boolean istPrimzahl(int n) {
int counter = 2;
boolean value = true;
while(counter < n) {
if((n % counter) == 0) { value = false; }
counter++;
}
return value;
}

for(int x = 1; x < 1000; x++){
 if(istPrimzahl(x)) { 
  if((909947.0f / x) == Math.floor(909947.0f / x)) {
   System.out.println(x);
  }
 }
}
</eval>