give the out put of n=6,s=0;for(int i=1;i<n;i++){if(n%i==0)s=s+i;}system.out.println(s);
Answers
Answered by
2
Answer:
6
Explanation:
itteration -1 : i = 1 , i < n (true), n%i==0 (true) , s=s+i = 0+1=1
itteration -2 : i = 2 ,i < n (true), n%i==0 (true) , s=s+i = 1+2 =3
itteration -3 : i = 3 ,i < n (true), n%i==0 (true) , s=s+i = 3+3=6
itteration -4 : i = 4 , i < n (true), n%i==0 (false) , s = 6
itteration -5 : i = 5 , i < n (true), n%i==0 (false) , s = 6
itteration -6 : i = 6 , i < n (false), s = 6
System.out.println(s) = 6
-----Hope this answer will help you..:)
hemabindu:
ssss tq for the help
Similar questions