python 判断质数还是合数

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