For a given number n, you can run a loop for i from 1 to n - 1: if i divides n, then add i to a special variable-accumulator (before the loop, this variable has to be initialized to zero). This way, after the loop ends, the accumulator will contain the sum of the divisors of n.