Skip to content

Commit 331c430

Browse files
authored
solve: 코딩테스트 문제 풀이 - 28일차프로그래머스_멀쩡한 사각형
1 parent 63d2958 commit 331c430

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public long solution(int w, int h) {
3+
long gcdVal = gcd(w, h);
4+
return (long)w * h - (w + h - gcdVal);
5+
}
6+
private long gcd(long a, long b) {
7+
while (b != 0) {
8+
long temp = b;
9+
b = a % b;
10+
a = temp;
11+
}
12+
return a;
13+
}
14+
}

0 commit comments

Comments
 (0)