Solution for programming task 2

This is the completed code for cached inverse problem