I have question about diagonal matrix that I have to generate without using any matrix function? : [enter image description here][1]
I have to generate the matrix above but I have some restrictions.
I am not allowed to use any build in functions such as matrix(),cbind,rbind (except length()) and any loop.I must use apply function for this problem

the function have only one parameter lets say 7 to generate this matrix above.



Any thoughts?


My approach is to this problem is I have to have a starting vector and then convert this starting vector to a matrix by using sapply function.And then operate on that matrix to get the required output.


  [1]: https://i.stack.imgur.com/uBEzU.png