I wrote Goldbach's theorem in java

Goldbach's theorem ... All even numbers can be represented by the sum of prime numbers. Let's write this theorem in java.

public class Qiita {
public static void main(String[] args) {
	boolean bl=true;
	int num=0;
	int n=6;
	String ans="";
	int[] sosuu=new int[24];

	for(int i=3; i<=100; i++) {
		for(int j=2; j<=(i/2); j++) {
			if(i%j==0){
				bl=false;
			}
		}
		if(bl==true){
			sosuu[num]=i;
			num++;
		}else{
			bl=true;
		}
	}
	while(n<=100) {
		for(int i=0; i<24; i++) {
			for(int j=0; j<24; j++) {
				if(n==(sosuu[i]+sosuu[j]) &&i<=j) {
		ans+="["+sosuu[i]+","+sosuu[j]+"]";
				}
			}
		}
		System.out.print(n+"\t"+":"+ans);
		ans="";
		System.out.println();
		n+=2;
	}
}
}

I used too much for and the program got dirty, but I managed to complete it.

Recommended Posts

I wrote Goldbach's theorem in java
I wrote a primality test program in Java
I wrote a prime factorization program in Java
I made roulette in Java.
I tried metaprogramming in Java
I wrote about Java downcast in an easy-to-understand manner
I sent an email in Java
I created a PDF in Java.
I made an annotation in Java.
I tried using JWT in Java
I wrote a Stalin sort that feels like a mess in Java
[Java] I participated in ABC-188 of Atcorder.
I tried using Elasticsearch API in Java
I tried the new era in Java
I did OpenCV camera calibration in Java
[* Java *] I participated in JJUG CCC 2019 Spring
Partization in Java
Changes in Java 11
I wrote EX25 of AtCoder Programming Guide for beginners (APG4b) in java.
I wrote a Lambda function in Java and deployed it with SAM
Pi in Java
FizzBuzz in Java
I made a primality test program in Java
I want to send an email in Java.
I tried to implement deep learning in Java
I wanted to make (a == 1 && a == 2 && a == 3) true in Java
I made a rock-paper-scissors game in Java (CLI)
rsync4j --I want to touch rsync in Java.
What I learned in Java (Part 2) What are variables?
I tried to output multiplication table in Java
I tried to create Alexa skill in Java
[java] sort in list
Read JSON in Java
Interpreter implementation in Java
Make Blackjack in Java
I made a simple calculation problem game in Java
I tried Mastodon's Toot and Streaming API in Java
Rock-paper-scissors app in Java
Constraint programming in Java
Put java8 in centos7
I want to do something like "cls" in Java
NVL-ish guy in Java
Combine arrays in Java
I first touched Java ②
Callable Interface in Java
I tried using Google Cloud Vision API in Java
I first touched Java ③
Comments in Java source
I want to use ES2015 in Java too! → (´ ・ ω ・ `)
Azure functions in java
# 2 [Note] I tried to calculate multiplication tables in Java.
Format XML in Java
Simple htmlspecialchars in Java
I tried to create a Clova skill in Java
Boyer-Moore implementation in Java
Hello World in Java
I tried to make a login function in Java
Use OpenCV in Java
webApi memorandum in java
What I learned in Java (Part 3) Instruction execution statement
Type determination in Java