코딩 공부 연습

프로그래머스 약수의 합

miffy짱 2022. 8. 9. 16:32
반응형
#include <string>
#include <vector>

using namespace std;

int solution(int n) {
    int answer = 0;
    for(int i = 1; i <= n; i++)
    {
        if (n%i == 0)
            answer+=i;
    }
    return answer;
}