We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 019e871 commit 0570ba3Copy full SHA for 0570ba3
프로그래머스/2/12953. N개의 최소공배수/N개의 최소공배수.py
@@ -1,10 +1,10 @@
1
+import math
2
+
3
def solution(arr):
- A = 1
- 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
+ def lcm(a, b):
+ return (a*b) // math.gcd(a, b)
+ ans = arr[0]
+ for i in range(1, len(arr)):
+ ans = lcm(ans, arr[i])
+ return ans
프로그래머스/2/12953. N개의 최소공배수/README.md
@@ -4,7 +4,7 @@
### 성능 요약
-메모리: 10.2 MB, 시간: 5405.61 ms
+메모리: 9.25 MB, 시간: 0.01 ms
### 구분
@@ -16,7 +16,7 @@
16
17
### 제출 일자
18
19
-2024년 08월 12일 15:50:18
+2026년 01월 05일 14:46:30
20
21
### 문제 설명
22
0 commit comments