Aliquot sum | CPP program for aliquot sum ; Function to calculate sum of all proper divisors ; Driver Code
#include <iostream> NEW_LINE using namespace std ; int aliquotSum ( int n ) { int sum = 0 ; for ( int i = 1 ; i < n ; i ++ ) if ( n % i == 0 ) sum += i ; return sum ; } int main ( ) { int n = 12 ; cout << aliquotSum ( n ) ; return 0 ; }