Check whether the number can be made perfect square after adding 1 | Function that returns true if x is a perfect square ; Find floating point value of square root of x ; If square root is an integer ; Function that returns true if n is a sunny number ; If ( n + 1 ) is a perfect square ; Driver code
function isPerfectSquare ( x ) { let sr = Math . sqrt ( x ) ; return ( ( sr - Math . floor ( sr ) ) == 0 ) ; } function isSunnyNum ( n ) { if ( isPerfectSquare ( n + 1 ) ) return true ; return false ; } let n = 3 ; if ( isSunnyNum ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;