C/C++程式訓練6---歌德巴赫猜想的證明(類)
阿新 • • 發佈:2019-02-08
import java.util.Scanner; class prime { int n; public prime(int n) { this.n = n; } public int show() { int i; for(i=2; i<n; i++) { if(n%i==0) { break; } } if(i>=n) { return 1; } else { return 0; } } } public class Main { public static void main(String[] args) { Scanner reader = new Scanner(System.in); int n = reader.nextInt(); for(int i=3; i<n; i++) { prime a = new prime(i); prime b = new prime(n-i); if(a.show()==1&&i%2==1&&b.show()==1&&(n-i)%2==1) { System.out.printf("%d=%d+%d\n",n,i,n-i); break; } } } }