-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprog1.java
More file actions
46 lines (40 loc) · 894 Bytes
/
prog1.java
File metadata and controls
46 lines (40 loc) · 894 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*Amazon(level-easy)
Given a number n, the task is to find the even factor sum of a number.
INPUT : The first line consists of an integer T i.e. the number of test cases. First and last line of each test case consists of an integer n.
OUTPUT : Print the sum of even factors of the given integer n.
CONSTRAINTS :
1<=T<=100
1<=n<=105
EXAMPLES:
INPUT :
2
30
18
OUTPUT :
48
26
*/
import java.util.Scanner;
public class prog1
{
public static void main(String[] args) {
int sum=0;
Scanner sc=new Scanner(System.in);
System.out.println("Inputs:");
int t=sc.nextInt();
int[] num=new int[t];
for(int i=0;i<t;i++){
num[i] = sc.nextInt();
}
System.out.println("Output:");
for(int i=0;i<t;i++){
for(int j=1;j<=num[i];++j){
if(num[i]%j == 0 && j%2==0){
sum=sum+j;
}
}
System.out.println(sum);
sum=0;
}
}
}