Implemented cumprod function similar to numpy's one.