+ 1
Why it is showing 0 in second time?
public class Program { public static void main(String[] args) { int n=94; int sum=0; int i=2; while(n>0) { sum+=n%10; n/=10; } System.out.println (sum); sum=0; while(n>1) { if(n%i==0) { sum+=i; } else i++; } System.out.println (sum); } }
1 Réponse
+ 4
"n" is 0 after the first while loop