判断是不是素数
Posted xderbyy
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了判断是不是素数相关的知识,希望对你有一定的参考价值。
//判断一个数是不是素数
#include <stdio.h>
int main()
{
int t;
while(1)
{
scanf("%d",&t);
int i,x,z=0;
for(i=1;i<t;i++)
{
x=t%i;
if(x==0)
z++;
}
if(z<2)
printf("该数是素数。
");
else
printf("该数不是素数。
");
}
}
以上是关于判断是不是素数的主要内容,如果未能解决你的问题,请参考以下文章