Skip to content

Commit be7dd58

Browse files
authored
[20251217] PGM / Lv2 / N개의 최소공배수 / 이강현
1 parent 291f956 commit be7dd58

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
```java
2+
import java.util.*;
3+
class Solution {
4+
public int solution(int[] arr) {
5+
int lcm = arr[0];
6+
for(int i = 1; i<arr.length; i++){
7+
lcm = LCM(lcm,arr[i]);
8+
}
9+
return lcm;
10+
}
11+
public int GCD(int a, int b) {return b == 0 ? a : GCD(b, a%b);}
12+
public int LCM(int a, int b) {return (a*b) / GCD(a,b);}
13+
14+
}
15+
```

0 commit comments

Comments
 (0)