;Task:
Build an &nbsp; [[wp:identity matrix|identity matrix]] &nbsp; of a size known at run-time.


An ''identity matrix'' is a square matrix of size '''''n'' &times; ''n''''',
<br>where the diagonal elements are all '''1'''s (ones),
<br>and all the other elements are all '''0'''s (zeroes).


<math>I_n = \begin{bmatrix}
  1      & 0      & 0      & \cdots & 0      \\
  0      & 1      & 0      & \cdots & 0      \\
  0      & 0      & 1      & \cdots & 0      \\
  \vdots & \vdots & \vdots & \ddots & \vdots \\
  0      & 0      & 0      & \cdots & 1      \\
\end{bmatrix}</math>


;Related tasks:
* &nbsp; [[Spiral matrix]]
* &nbsp; [[Zig-zag matrix]]
* &nbsp; [[Ulam_spiral_(for_primes)]]
<br><br>
