나의 개발일지

[프로그래머스] Lv.2 N개의 최소공배수 [Python, 파이썬] 본문

프로그래머스

[프로그래머스] Lv.2 N개의 최소공배수 [Python, 파이썬]

YoonJuHan 2023. 8. 29. 19:14

 

def solution(arr):
    answer = 0
    
    b = True
    cnt = 1
    
    while b:
        n = arr[-1] * cnt   # 제일 큰 수 * cnt
        
        for i in range(len(arr)-1):
            if n % arr[i] == 0:
                b = False
            else:            # 나누어 떨어지지 않으면
                b = True     # 계속 반복       
                cnt += 1
                break
                
    return n
Comments