Calculate prime numbers in Java

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

Calculate prime numbers in Java
How to find Java prime numbers
Partization in Java
Changes in Java 11
Rock-paper-scissors in Java
Judge prime numbers
Pi in Java
FizzBuzz in Java
Generate normal distribution / lognormal distribution random numbers in Java
[Java] Find prime numbers with an Eratosthenes sieve
Distinguish between positive and negative numbers in Java
I wrote a prime factorization program in Java
[java] sort in list
Read JSON in Java
Interpreter implementation in Java
Make Blackjack in Java
Rock-paper-scissors app in Java
Constraint programming in Java
Put java8 in centos7
Combine arrays in Java
"Hello World" in Java
Callable Interface in Java
Comments in Java source
Azure functions in java
Format XML in Java
Simple htmlspecialchars in Java
Boyer-Moore implementation in Java
Hello World in Java
Use OpenCV in Java
webApi memorandum in java
Type determination in Java
Ping commands in Java
Various threads in java
Zabbix API in Java
ASCII art in Java
Compare Lists in Java
POST JSON in Java
Express failure in Java
Create JSON in Java
Date manipulation in Java 8
What's new in Java 8
Use PreparedStatement in Java
What's new in Java 9,10,11
Parallel execution in Java
Initializing HashMap in Java
[Java] Find prime numbers with an Eratosthenes sieve (Part 2)
Calculate the difference between numbers in a Ruby array
Try using RocksDB in Java
Read binary files in Java 1
Avoid Yubaba's error in Java
Get EXIF information in Java
Save Java PDF in Excel
[Neta] Sleep Sort in Java
Edit ini in Java: ini4j
Java history in this world
Let Java segfault in 6 lines
Try calling JavaScript in Java
Try developing Spresense in Java (1)
Try functional type in Java! ①
Create hyperlinks in Java PowerPoint
Implement two-step verification in Java