Update cachematrix.R

Made the necessary additions to the code as required in the assignment.