#include <math.h>
void isPrium(int n)
{
int i
for(i=2i<sqrt(n)i++)
if(n%i == 0)
return 0
return 1
}
void main()
{
int n
while(scanf("%d",&n))
{
if(isPrium(n))
printf("n是素数!\n",n)
else
printf("n不是素数!\n",n)
}
}
满意请采纳
Dim x As Integer, i As Integerx = InputBox("请输入你要判断的数字")
If x <= 0 Then
MsgBox "你输入的不是正整数"
Exit Sub
End If
For i = 2 To x - 1
If x Mod i = 0 Then
MsgBox x &"不是素数"
Exit Sub
End If
Next
MsgBox x &"是素数"
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)