Superperfect Number | Function to calculate sum of all divisors ; Final result of summation of divisors ; find all divisors which divides ' num ' ; if ' i ' is divisor of ' num ' ; if both divisors are same then add it only once else add both ; Returns true if n is Super Perfect else false . ; Find the sum of all divisors of number n ; Again find the sum of all divisors of n1 and check if sum is equal to n1 ; Driver code
< ? php function divSum ( $ num ) { $ result = 0 ; for ( $ i = 1 ; $ i * $ i <= $ num ; ++ $ i ) { if ( $ num % $ i == 0 ) { if ( $ i == ( $ num / $ i ) ) $ result += $ i ; else $ result += ( $ i + $ num / $ i ) ; } } return $ result ; } function isSuperPerfect ( $ n ) { $ n1 = divSum ( $ n ) ; return ( 2 * $ n == divSum ( $ n1 ) ) ; } $ n = 16 ; $ hh = ( isSuperPerfect ( $ n ) ? " Yes STRNEWLINE " : " No STRNEWLINE " ) ; echo ( $ hh ) ; $ n = 6 ; $ hh = ( isSuperPerfect ( $ n ) ? " Yes STRNEWLINE " : " No STRNEWLINE " ) ; echo ( $ hh ) ; ? >