[Programmers] N개의 최소공배수
Python
import math
def solution(arr):
answer = arr[0]
for i in range(1, len(arr)):
answer = (answer * arr[i]) // math.gcd(answer, arr[i])
return answer
import math
def solution(arr):
answer = arr[0]
for i in range(1, len(arr)):
answer = (answer * arr[i]) // math.gcd(answer, arr[i])
return answer
댓글남기기