1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | num = 10 divisors = [] for i in range(2, num): if num % i == 0: divisors.append(i) print(num,'ÀÇ Áø¾à¼ö :', divisors) ############################################ def get_divisors(num): # numÀÇ ¾à¼ö¸¦ ÁýÇÕÇüÀ¸·Î ¹ÝȯÇÔ divisors = set() for i in range(2, num): if num % i == 0: divisors.add(i) return divisors x = 48 print(x, 'ÀÇ Áø¾à¼ö :', get_divisors(x)) y = 60 print(y, 'ÀÇ Áø¾à¼ö :', get_divisors(y)) ############################################ A = get_divisors(x) B = get_divisors(y) print(A.intersection(B)) print(x, y,'ÀÇ ÃÖ´ë°ø¾à¼ö :', max(A.intersection(B))) | cs |