while 1: s = input('请输入一个数:') s = int(s) if s == 2: print('质数') else: if s == 0 or s == 1: print('都不是') else: u = s - 2 h = 1 p = 1 while u: h = h + 1 if s % h == 0: p = 1 break else: p = 0 u = u - 1 if p: print('合数') else: print('质数')
本文共 478 字,大约阅读时间需要 1 分钟。
while 1: s = input('请输入一个数:') s = int(s) if s == 2: print('质数') else: if s == 0 or s == 1: print('都不是') else: u = s - 2 h = 1 p = 1 while u: h = h + 1 if s % h == 0: p = 1 break else: p = 0 u = u - 1 if p: print('合数') else: print('质数')
转载于:https://www.cnblogs.com/wumac/p/5624832.html