Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| 31 |
Tags
- 백준
- binary search
- MySQL
- db
- 건강
- SWEA
- SQL
- 자바
- math
- 시뮬레이션
- 투포인터
- priorityqueue
- BFS
- 프로그래머스
- 코테
- 코딩테스트
- 러닝일지
- COS PRO
- 운동기록
- 알고리즘
- BOJ
- dfs
- greedy
- oracle
- 문제풀이
- Java
- 문자열
- 이분탐색
- 문제해결
- DP
Archives
- Today
- Total
슈콩
COS PRO 1급 JAVA 공약수 구하기 본문


[소스 코드]
class Main {
public int func_a(int a, int b) {
int mod = a % b;
while(mod > 0) {
a = b;
b = mod;
mod = a % b;
}
return b;
}
public int func_b(int n) {
int answer = 0;
for(int i = 1; i <= n; i++) {
if(func_c(n,i))
answer++;
}
return answer;
}
public boolean func_c(int p, int q) {
if(p % q == 0)
return true;
else
return false;
}
public int solution(int a, int b, int c) {
int answer = 0;
int gcd = func_a(func_a(a, b), c);
answer = func_b(gcd);
return answer;
}
}