Find other two sides of a right angle triangle | Finds two sides of a right angle triangle if it they exist . ; if n is odd ; case of n = 1 handled separately ; case of n = 2 handled separately ; Driver code
function printOtherSides ( n ) { if ( n % 2 != 0 ) { if ( n == 1 ) document . write ( " " ) ; else { var b = ( n * n - 1 ) / 2 ; var c = ( n * n + 1 ) / 2 ; document . write ( " " + b + " " + c ) ; } } else { if ( n == 2 ) document . write ( " " ) ; else { var b = n * n / 4 - 1 ; var c = n * n / 4 + 1 ; document . write ( " " + b + " " + c ) ; } } } var a = 3 ; printOtherSides ( a ) ;