Advertisement
Albert3069

과제

May 7th, 2020
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.89 KB | None | 0 0
  1. import sys
  2. while True:
  3.     def prime_number(g):
  4.         if g > 10000:
  5.             print("1에서 10000 사이의 정수를 입력해야 합니다.\n")
  6.             return False
  7.         elif g < 1:
  8.             print("1에서 10000 사이의 정수를 입력해야 합니다.\n")
  9.             return False
  10.         elif g != 1:
  11.             for f in range(2, g):
  12.                 if g % f == 0:
  13.                     return False
  14.         else:
  15.             return False
  16.  
  17.         return True
  18.  
  19.     g = int(input("1에서 10000 사이의 정수를 입력하세요."))
  20.  
  21.     if g is 1:
  22.         print("1입니다.")
  23.     elif prime_number(int(g)):
  24.         print("소수입니다.")
  25.     else:
  26.         divisor = []
  27.         num = int(g/2)
  28.  
  29.         divisor.append(g)
  30.         while num >= 1:
  31.             if g % num == 0 :
  32.                 divisor.append(num)
  33.             num -= 1
  34.  
  35.         print(divisor)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement