Check if N can be represented as sum of squares of two consecutive integers | Function to check that the a number is sum of squares of 2 consecutive numbers or not ; Condition to check if the a number is sum of squares of 2 consecutive numbers or not ; Driver code ; Function call
function isSumSquare ( N ) { var n = ( 2 + Math . sqrt ( 8 * N - 4 ) ) / 2 ; return ( n - parseInt ( n ) ) == 0 ; } var i = 13 ; if ( isSumSquare ( i ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }