L2 : N개의 최소공배수 Python

jhyunn·2023년 1월 25일
0

Programmers

목록 보기
69/69

L2 : N개의 최소공배수 Python

https://school.programmers.co.kr/learn/courses/30/lessons/12953

import math
def solution(arr):
    while len(arr) > 1:
        a = arr.pop()
        b = arr.pop()
        arr.append(a*b // math.gcd(a, b))
    return arr[0]

#math #gcd #공약수 #최대공약수 #공배수 #최소공배수

profile
https://github.com/Sungjeonghyun

0개의 댓글