Skip to content

Commit 0570ba3

Browse files
committed
[level 2] Title: N개의 최소공배수, Time: 0.01 ms, Memory: 9.25 MB -BaekjoonHub
1 parent 019e871 commit 0570ba3

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import math
2+
13
def solution(arr):
2-
A = 1
3-
for i in arr:
4-
A *= i
5-
for i in range(2, A+1):
6-
cnt = 0
7-
for j in arr:
8-
if i % j == 0: cnt += 1
9-
if cnt == len(arr): return i
10-
return A
4+
def lcm(a, b):
5+
return (a*b) // math.gcd(a, b)
6+
7+
ans = arr[0]
8+
for i in range(1, len(arr)):
9+
ans = lcm(ans, arr[i])
10+
return ans

프로그래머스/2/12953. N개의 최소공배수/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### 성능 요약
66

7-
메모리: 10.2 MB, 시간: 5405.61 ms
7+
메모리: 9.25 MB, 시간: 0.01 ms
88

99
### 구분
1010

@@ -16,7 +16,7 @@
1616

1717
### 제출 일자
1818

19-
2024년 08월 12일 15:50:18
19+
2026년 01월 05일 14:46:30
2020

2121
### 문제 설명
2222

0 commit comments

Comments
 (0)