It's a simple method without any ingenuity, but it's quite interesting, such as getting a prime number of 7978889 just by turning it for about an hour.
package sosuu;
public class ListSosuuMain {
public static void main(String[] args) {
for (int n = 0; n < Integer.MAX_VALUE; n++) {
if (isSosuu(n) == true) {
System.err.println(n);
}
}
}
public static boolean isSosuu(int n) {
for (int m = 2; m < n; m++) {
if (n % m == 0) {
return false;
}
}
return true;
}
}
Recommended Posts