Updated the cachematrix.R by referring to the example provided in the assignment

TODO: Test if the code is working as expected.