Largest N digit Octal number which is a Perfect square | Function to convert decimal number to a octal number ; Array to store octal number ; Counter for octal number array ; Store remainder in octal array ; Print octal number array in reverse order ; Largest n - digit perfect square ; Driver Code
function decToOctal ( n ) { var octalNum = Array ( 100 ) . fill ( 0 ) ; var i = 0 ; while ( n != 0 ) { octalNum [ i ] = n % 8 ; n = parseInt ( n / 8 ) ; i ++ ; } for ( var j = i - 1 ; j >= 0 ; j -- ) document . write ( octalNum [ j ] ) ; document . write ( " " ) ; } function nDigitPerfectSquares ( n ) { var decimal = Math . pow ( Math . ceil ( Math . sqrt ( Math . pow ( 8 , n ) ) ) - 1 , 2 ) ; decToOctal ( decimal ) ; } var n = 2 ; nDigitPerfectSquares ( n ) ;