728x90
반응형
SMALL
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
int gcd(int a,int b) // a > b
{
if(b==0)
return a;
else
return gcd(b, a % b);
}
int lcm(int a,int b)
{
return a*b/gcd(a,b);
}
int solution(int n) {
//n과 6의 최소 공배수를 구하기
return lcm(n,6)/6;
}
728x90
반응형
LIST
'C++' 카테고리의 다른 글
[프로그래머스] 배열의 평균값 (0) | 2025.09.02 |
---|---|
[프로그래머스] 피자 나눠 먹기(3) (0) | 2025.09.02 |
[프로그래머스] 피자 나눠 먹기(1) (0) | 2025.09.02 |
[프로그래머스] 짝수는 싫어요 (0) | 2025.09.01 |
[프로그래머스] 최빈값 구하기 (수정중) (0) | 2025.09.01 |
댓글