Check if a number is a perfect square having all its digits as a perfect square | Function to check if digits of N is a perfect square or not ; Iterate over the digits ; Extract the digit ; Check if digit is a perfect square or not ; Divide N by 10 ; Return true ; Function to check if N is a perfect square or not ; If floor and ceil of n is not same ; Function to check if N satisfies the required conditions or not ; If both the conditions are satisfied ; Driver Code ; Function Call
function check_digits ( N ) { while ( N > 0 ) { let n = N % 10 ; if ( ( n != 0 ) && ( n != 1 ) && ( n != 4 ) && ( n != 9 ) ) { return 0 ; } N = Math . floor ( N / 10 ) ; } return 1 ; } function is_perfect ( N ) { let n = Math . sqrt ( N ) ; if ( Math . floor ( n ) != Math . ceil ( n ) ) { return 0 ; } return 1 ; } function isFullSquare ( N ) { if ( is_perfect ( N ) && check_digits ( N ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; } } let N = 144 ; isFullSquare ( N ) ;