C/C++程序训练6---歌德巴赫猜想的证明

来源:互联网 发布:广州金针软件 编辑:程序博客网 时间:2024/05/16 08:12

C/C++程序训练6---歌德巴赫猜想的证明

Time Limit: 1000MSMemory Limit: 65536KB
SubmitStatistic

Problem Description

验证“每个不小于6的偶数都是两个素数之和”,输入一个不小于6的偶数n,找出两个素数,使它们的和为n。

Input

输入一个不小于6的偶数n。

Output

找出两个素数,使它们的和为n。只需要输出其中第一个素数最小的一组数据即可。

Example Input

80

Example Output

80=7+73

Hint

Author

 
#include<stdio.h>
int c(int n);
int main()
{
    int n,i;
    scanf("%d",&n);
    for(i=2;i<n/2;i++)
    {
        if(c(i)&&c(n-i))
        {
            printf("%d=%d+%d\n",n,i,n-i);
            break;
        }
    }
    return 0;
}
int c(int n)
{
    int i;
    for(i=2;i<n;i++)
        if(n%i==0) return 0;
    return 1;

}

阅读全文
0 0
原创粉丝点击