- Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP21.java
30 lines (21 loc) · 530 Bytes
/
P21.java
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
importjava.util.Scanner;
publicclassP21 {
publicstaticvoidmain(String[] args)
{
Scannerinput=newScanner (System.in);
System.out.println("Please enter n:");
intn=input.nextInt();
intsum=0;
intcount=0;
for (intx=1 ; x<=n ; x++)
if (n%x==0)
{
count++;
sum = sum + x;
System.out.println(x);
}
System.out.println("sum is : " + sum);
System.out.println("count is : " + count);
System.out.println("Avg is :" + 1.0 * sum/count);
}
}