Update cachematrix.R

Initial check-in. Tested the code in RStudio.