Magnesium ribbon was allowed to burn inside a given gas P leaving a white solid…