Update cachematrix.R

Completed the assignment as asked by instructors.