No sweet without sweat

[LV.1 프로그래머스] 약수의 합 본문

프로그래머스

[LV.1 프로그래머스] 약수의 합

Remi 2023. 1. 17. 00:19
728x90
반응형

class Solution {
    public int solution(int n) {
         int answer = 0;
        for(int i=1; i<=n; i++){
            if((n%i) ==0) {
                //System.out.print(i);
                answer += i;
            }
        }
        
       
        return answer;
    }
}
728x90
반응형
Comments