Untitled
unknown
java
a year ago
486 B
7
Indexable
import java.util.Scanner;
public class P1 {
public static int Sol(int n) {
int sumValue = 1;
for (int i = 2; i < n; i++) {
if (n % i == 0) {
sumValue += i;
if (sumValue >= n) {
sumValue -= i;
break;
}
}
}
return sumValue;
}
// 6 = 1, 2, 3, 6
// 8 = 1,2 ,4,8
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
System.out.println(Sol(n));
// Sol(n);
}
}
Editor is loading...
Leave a Comment