brewersfan1976

matrix-trace.rb

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