已经族芦为你修改好了:
#include<stdio.h>
#include<math.h>
int f(int n)
{
int i
for(i=2i<=sqrt(n)i++)
迟兆 if(n%i==0)return 0
return 1
}
int main()
{
int n,i
do
{scanf("%d",&n)
if(n==0)break
if(n%2==0)
{ for(i=3!f(i)||!f(n-i)i+=2)
printf("%d=%d+%d\n",n,i,n-i)
}
else
printf("%d is odd number!\n"码穗租,n)
}
while(n!=0)
return 0
}
# _*_coding:utf-8 _*_# @Time :2018/10/25 13:27
# @Author :mrgui
# @FileName: print_prime.py
# @Software: PyCharm
def is_prime(num):
for i in range(2, num // 2 + 1):
团拿 if num % i == 0:
return False
return True
if __name__ == '__main__':
while True:
n = 塌指搭eval(input("请输入一个数,判断是否为质数:"))
if isinstance(n, int) and n > 2:
break
else:
逗绝 print('输入的数必须是一个大于2的整数...')
for i in range(2, n):
if is_prime(i):
print(i)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)