问题描述:
It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a prime and twice a square.
9 = 7 + 2
12
15 = 7 + 2
22
21 = 3 + 2
32
25 = 7 + 2
32
27 = 19 + 2
22
33 = 31 + 2
12
It turns out that the conjecture was false.
What is the smallest odd composite that cannot be written as the sum of a prime and twice a square?
解决问题:
int i =33;
boolean ok = true;
for(;ok;){
i=i+2;
int j;
if(IsPrime(i)){
for( j=1; 2*j*j<i; j++){
if(IsPrime(i-2*j*j)){
break;
}
}
if(2*j*j>=i){
System.out.println("j:"+j+".i:"+i);
ok = false;
}
}
}
1038

被折叠的 条评论
为什么被折叠?



