text: Anti | Iterative function to reverse digits of num ; Return the reversed num ; Function to calculate sum of reverse all proper divisors ; Final result of summation of divisors ; Find all divisors of num ; If ' i ' is divisor of ' num ' ; If both divisors are same then add it only once else add both ; Add 1 to the result as 1 is also a divisor ; Function to check if N is anti - perfect or not ; Given Number N ; Function Call
code: function rev ( num ) { var rev_num = 0 ; while ( num > 0 ) { rev_num = rev_num * 10 + num % 10 ; num = Math . floor ( num / 10 ) ; } return rev_num ; } function divSum ( num ) { var result = 0 ; for ( var i = 2 ; i <= Math . floor ( Math . sqrt ( num ) ) ; i ++ ) { if ( num % i == 0 ) { if ( i == ( num / i ) ) result += rev ( i ) ; else result += ( rev ( i ) + rev ( num / i ) ) ; } } result += 1 ; return result ; } function isAntiPerfect ( n ) { return divSum ( n ) == n ; } var N = 244 ; if ( isAntiPerfect ( N ) ) document . write ( " " ) ; else document . write ( " " ) ;