C++:: 프로그래머스 < 약수의 합 >

jahlee·2023년 8월 7일
0

프로그래머스_Lv.1

목록 보기
62/75
post-thumbnail

약수의 합을 구하면 되는 간단한 문제이다.

#include <string>
#include <vector>

using namespace std;

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

0개의 댓글