Skip to main content

Aliquot Sum

In number theory, the aliquot sum s(n) of a positive integer n is the sum of all proper divisors of n, that is, all divisors of n other than n itself.

They are defined by the sums of their aliquot divisors. The aliquot divisors of a number are all of its divisors except the number itself. The aliquot sum is the sum of the aliquot divisors so, for example, the aliquot divisors of 12 are 1, 2, 3, 4, and 6 and it’s aliquot sum is 16.



function aliquot(n)
{
  var sum = 0;
  for(var i = 1; i < n; i++)
  if(n % i === 0) sum += i;
  return sum;
}