Skip to content

Commit 9d5b874

Browse files
authored
Create 프로그래머스_멀쩡한사각형.java
1 parent dd24dfe commit 9d5b874

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public long solution(int w, int h) {
3+
long w1 = w;
4+
long h1 = h;
5+
return w1 * h1 - (w1+h1 - gcd(w1,h1));
6+
7+
8+
}
9+
10+
public long gcd(long w,long h) {
11+
if (w % h == 0) {
12+
return h;
13+
} else {
14+
return gcd(h,w%h);
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)