• [deleted]
    + 0 comments

    put that i++ outside of if condition.

    int sum=0; int i=1; while(i<=n) { if(n%i==0) { sum+=i; } i++; }