Aliquot sum | Java program for aliquot sum ; Function to calculate sum of all proper divisors ; Driver Code
import java . io . * ; class GFG { static int aliquotSum ( int n ) { int sum = 0 ; for ( int i = 1 ; i < n ; i ++ ) if ( n % i == 0 ) sum += i ; return sum ; } public static void main ( String args [ ] ) throws IOException { int n = 12 ; System . out . println ( aliquotSum ( n ) ) ; } }