Closed ji-0630 closed 1 year ago
import math
def solution(a, b):
n = math.gcd(a,b)
a = a//n
b = b//n
lst = []
i = 2
while(b!=1):
if b % i == 0:
lst.append(i)
b = b//i
else:
i+=1
print(lst)
if len(set(lst) - {2,5}) == 0:
return 1
else:
return 2
from math import gcd
def solution(a, b):
b //= gcd(a,b)
while b%2==0:
b//=2
while b%5==0:
b//=5
return 1 if b==1 else 2
문제 설명