Generate a matrix having sum of secondary diagonal equal to a perfect square | Function to prlet the matrix whose sum of element in secondary diagonal is a perfect square ; Iterate for next N - 1 rows ; Prlet the current row after the left shift ; Given N ; Fill the array with elements ranging from 1 to N ; Function Call
function diagonalSumPerfectSquare ( arr , N ) { for ( let i = 0 ; i < N ; i ++ ) { for ( let j = 0 ; j < N ; j ++ ) { document . write ( arr [ ( j + i ) % 7 ] + " " ) ; } document . write ( " " ) ; } } let N = 7 ; let arr = new Array ( N ) . fill ( 0 ) ; for ( let i = 0 ; i < N ; i ++ ) { arr [ i ] = i + 1 ; } diagonalSumPerfectSquare ( arr , N ) ;