Refactorable number | Function to count all divisors ; Initialize result ; If divisors are equal , count only one . ; Otherwise count both ; Driver Code
function isRefactorableNumber ( n ) { let divCount = 0 ; for ( let i = 1 ; i <= Math . sqrt ( n ) ; ++ i ) { if ( n % i == 0 ) { if ( n / i == i ) ++ divCount ; else divCount += 2 ; } } return n % divCount == 0 ; } let n = 8 ; if ( isRefactorableNumber ( n ) ) document . write ( " " + " " ) ; else document . write ( " " + " " ) ; n = 14 ; if ( isRefactorableNumber ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;