취준시절/프로그래머스

[프로그래머스] N개의 최소 공배수 - Python

MAYMIN 2021. 8. 4. 22:11
728x90
SMALL
from math import gcd

def solution(arr):
    def lcm(x,y):
        return x*y // gcd(x,y)
    while True:
        arr.append(lcm(arr.pop(),arr.pop()))
        if len(arr)==1:
            return arr[0]
728x90
LIST