同学甲:
shuzi = int(input("请输入一个数:"))
sum = 0
a = 0
while sum <= shuzi:
sum += 1
if shuzi % sum == 0:
sum = 0
a = 0
while sum <= shuzi:
sum += 1
if shuzi % sum == 0:
a = a + 1
print(a)
if a == 2 and a != 3:
print("质数为:", shuzi)
else:
print("不是质数")
print(a)
if a == 2 and a != 3:
print("质数为:", shuzi)
else:
print("不是质数")
同学乙
sum = int(input("请输入一个数:"))
count = 0
a = 0 #因数个数
while count <= sum:
count += 1
if sum % count == 0:
a += 1 #因数个数加一
if a > 2:
print("不是质数")
break
else:
print("是质数")
同学丙:
a=int(input("请输入数字"))
b=2
while a-1>b:
if a%b==0:
print("合数")
break
else:
b=b+1
else:
print("质数")
同学丁:
num = 0
content = int(input("请输入你要判断的数字:"))
if content == 1:
print("不是质数")
else:
while num <= content:
num += 1
if content >= num:
if content % num == 0:
a += 1
if a > 2:
print("不是质数")
break
else:
print("是质数")
: