-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSum_div.java
More file actions
28 lines (28 loc) · 732 Bytes
/
Sum_div.java
File metadata and controls
28 lines (28 loc) · 732 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.*;
public class Sum_div {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
long t = in.nextLong();
long sum = 0;
while(t-->0){
long n = in.nextLong();
if(n<2)
sum += 0;
else{
while(n%2 == 0){
sum += 2;
n/=2;
}
for(long i=3;i<= Math.sqrt(n);i+=2){
while(n%i == 0){
sum += i;
n /= i;
}
}
if(n>2)
sum += n;
}
}
System.out.println(sum);
}
}