class Solution { public int solution(int n) { int answer = 0; for(int i = 1; i <= n; i++){ if(n%i == 0){ answer += i; } else { continue; } }; return answer; } }
가장 작은 소수는 2임을 이용하여 주어진 수의 절반을 for문 범위에서 제외시킴