int prime( int p )//判断素数
{
if(p==1) //p=1以及p=2或3
return 0;
if(p==2||p==3)
return 1;
for(int i=2;i<=sqrt(p);i++)
if(p%i==0)
return 0;
return 1;
}
void Goldbach( int n )
{
int t;
for(int i=1;i<n;i+=2)
{
if(prime(i))
{
t=n-i;
if(prime(t))
{
printf("%d=%d+%d",n,i,t);
break;
}
}
}
}
6-5 using the function authentication Problem pta Goldbach conjecture (20 minutes)
Guess you like
Origin blog.csdn.net/superman_lile/article/details/104525651
Recommended
Ranking