I am trying to make a nxn matrix with a pattern like so: Matrix
Where if n is given it will have the nxn matrix as the output. For example if n = 5, the expected output would be:
[[ 1 0 0 0 0]
[-1 1 0 0 0]
[ 0 -1 1 0 0]
[ 0 0 -1 1 0]
[ 0 0 0 -1 1]]
Can anyone help me to device the algorithm for generating the matrix in the same pattern with n as the input? Thank you for the help