返回列表 發帖
本帖最後由 張桔熙 於 2024-1-30 11:31 編輯
  1. def compute(x):
  2.     c=0
  3.    
  4.     for i in range(1,x+1):
  5.         if(x%i==0):
  6.             c+=1
  7.    
  8.     if(c==2):
  9.         return 1
  10.     else:
  11.         return 0
  12.    
  13. x=int(input())
  14. t=compute(x)

  15. if(t==1):
  16.     print(f"{x} is a prime number")
  17. else:
  18.     print(f"{x} is not a prime number")
複製代碼

TOP

返回列表