Multiply perfect number | Java implementation of the above approach ; Function to find the sum of divisors ; Note that this loop runs till square root of N ; If divisors are equal , take only one of them ; Otherwise take both ; Function to check Multiply - perfect number ; Driver code
class GFG { static int getSum ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) sum = sum + i ; else { sum = sum + i ; sum = sum + ( n / i ) ; } } } return sum ; } static boolean MultiplyPerfectNumber ( int n ) { if ( getSum ( n ) % n == 0 ) return true ; else return false ; } public static void main ( String [ ] args ) { int n = 28 ; if ( MultiplyPerfectNumber ( n ) ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } }