Updated cachematrix.R

updated cachematrix.R and tested with testCacheMatrix.R