brewersfan1976

matrix_trace.rb

Mar 2nd, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.20 KB | None | 0 0
  1. def matrixTrace(matrix)
  2.     x = 0
  3.     y = 0
  4.     sum = 0
  5.    
  6.     while (x < matrix.length)
  7.           sum = sum + matrix[x][y]
  8.           x = x + 1
  9.           y = y + 1
  10.     end
  11.    
  12.     return sum
  13. end
Advertisement
Add Comment
Please, Sign In to add comment