We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0f85284 commit 6b4625bCopy full SHA for 6b4625b
LiiNi-coder/202510/30 PGM N개의 최소공배수.md
@@ -0,0 +1,25 @@
1
+```java
2
+import java.util.*;
3
+
4
+class Solution {
5
+ public int solution(int[] arr) {
6
+ long lcm = arr[0];
7
+ for(int i=1; i<arr.length; i++){
8
+ lcm = lcm(lcm, arr[i]);
9
+ }
10
+ return (int)lcm;
11
12
+ private static long gcd(long a, long b){
13
+ while(b != 0){
14
+ long t = a % b;
15
+ a = b;
16
+ b = t;
17
18
+ return a;
19
20
+ private static long lcm(long a, long b){
21
+ return (a / gcd(a, b)) * b;
22
23
+}
24
25
+```
0 commit comments