1 parent 8326564 commit fe38abdCopy full SHA for fe38abd
2 files changed
프로그래머스/1/12928. 약수의 합/README.md
@@ -4,7 +4,7 @@
4
5
### 성능 요약
6
7
-메모리: 73.7 MB, 시간: 0.05 ms
+메모리: 85.8 MB, 시간: 0.02 ms
8
9
### 구분
10
@@ -16,7 +16,7 @@
16
17
### 제출 일자
18
19
-2026년 06월 21일 13:57:35
+2026년 06월 21일 14:04:23
20
21
### 문제 설명
22
프로그래머스/1/12928. 약수의 합/약수의 합.java
@@ -2,9 +2,13 @@ class Solution {
2
public int solution(int n) {
3
int ans = 0;
- for (int i = 1; i <= n; i++) {
+ for (int i = 1; i*i <= n; i++) {
if (n % i == 0) {
ans += i;
+
+ if (i != n /i) {
+ ans += n/i;
11
+ }
12
}
13
14
return ans;
0 commit comments