Identity Matrix

Question

Can you build a function that prints an identity matrix, given the identity matrix size?

Examples:

Input: 2
Output: 
       1 0
       0 1
         

Input: 4
Output: 
       1 0 0 0
       0 1 0 0
       0 0 1 0
       0 0 0 1

Solution

Access restricted

Subscribe to premium account to see the solution.

Get premium now