Hallo èner,
Allerding reicht bei diesem Projekt nach wenigen Tagen rechenarbeit der Datentyp long nicht mehr.
Bis 2^64 brauchst Du schon mehrere Tage? Ich hab mich mit dem Thema nie näher beschäftigt, wie testest Du denn Primalität einer Zahl?
Also ich hab jetzt einfach mal das hier geschrieben:
~~~java
public static void prim() {
long start = 0;
long end = 1;
long i = 0;
long cur;
boolean lost = false;
try {
String input;
BufferedReader inoutstream;
inoutstream = new BufferedReader(new InputStreamReader(System.in));
input = inoutstream.readLine();
start = Long.parseLong(input);
input = inoutstream.readLine();
end = Long.parseLong(input);
}
catch(IOException a) {
a.printStackTrace();
}
for (cur = start; cur <= end; ++cur) {
lost = false;
for (i = 2; (i*2) <= cur && lost != true; ++i) {
if ((cur % i) == 0) {
lost = true;
}
}
if (lost != true) {
System.out.println(cur + " ist eine Primzahl");
}
}
}
Natürlich muss ich das noch mit einem Client-Socket-Prinzip "kreuzen"...