Problem 459. Sum of diagonal of a square matrix

Created by Sunu

If

 x = [1 2 4; 3 4 5; 5 6 7]

then y should be the sum of the diagonals of the matrix

 y = 1 + 4 + 7 = 12

Problem Group

186 solvers submitted 251 solutions (1.35 solutions/solver).

Solution Comments