Aliquot sum | Function to calculate sum of all proper divisors ; Driver code
function aliquotSum ( n ) { let sum = 0 ; for ( let i = 1 ; i < n ; i ++ ) if ( n % i == 0 ) sum += i ; return sum ; } let n = 12 ; document . write ( aliquotSum ( n ) ) ;