那麼第一組找到的即是b-a相差最大的一組,即是所求。
[C](0.060)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int prime[1000005] = { 1, 0, 0 }; | |
int main() | |
{ | |
int i, j; | |
for( i = 2 ; i <= 1000000 ; i++ ) | |
if( !prime[i] ) | |
for( j = i+i ; j <= 1000000 ; j+=i ) | |
prime[j] = 1; | |
int n; | |
while( scanf( "%d", &n ) != EOF && n != 0 ) | |
{ | |
int print = 0; | |
for( i = 2 ; i <= n ; i++ ) | |
if( !prime[i] && !prime[n-i] ) | |
{ | |
printf( "%d = %d + %d\n", n, i, n-i ); | |
print = 1; | |
break; | |
} | |
if( !print ) | |
printf( "Goldbach's conjecture is wrong.\n" ); | |
} | |
return 0; | |
} |
0 意見:
張貼留言