验证哥德巴赫猜想

#include<stdio.h>
#include<math.h>
int sushu(int n);
int main()
{
	int i,j;
	for(i=6;i<=50;i=i+2)
	{
		for(j=2;j<i-1;j++)
		{
			if(sushu(j)==1&&sushu(i-j)==1)
			{
				printf("%d=%d+%d\n",i,j,i-j);
			}
		}
	}
	return 0;
}
int sushu(int n)
{
	int i=2;
	while(i<n)
	{
		if(n%i==0)
		{
			return 0;
		}
		i++;
	}
	return 1;
}

猜你喜欢

转载自blog.csdn.net/yxyy3604/article/details/12780553