Update cachematrix.R

Updated the code as per Programming assignment2 requirements.