For finding the sum of all the divisors of second number m
for ( let i = 2 ; i <= Math . sqrt ( m ) ; i ++ ) { if ( m % i == 0 ) { Sum2 += i + ( isPerfectSquare ( m ) ? 0 : parseInt ( m / i ) ) ; } } if ( ( n + 1 == Sum2 ) && ( m + 1 == Sum1 ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; } }