📖Algorithm/Simulation, Math
자바 [Programmers] 1단계 - 약수의 합
구동엽
2024. 2. 18. 01:14
class Solution {
public int solution(int n) {
int answer = 0;
for(int i=1; i<=n; i++){
if(n%i==0){
answer += i;
}
}
return answer;
}
}
약수를 구하는 간단한 코드
약수만 알고 있으면 구현은 매우 쉬운 문제