• + 5 comments

    I like this one, it's clean and easy to follow.

    Also, since it's a one liner for loop, you should be able to getaway with removing the curley braces.

    for (int i = 1; i <= n; i++) 
      if (n % i == 0) sum += i;