How can I add inertia to a rotation when I release the mouse?

I have an sphere, and I want to rotate it when I drag my mouse, but it stops when I release the mouse.
I pretend to continue the rotation after the dragging, slowing down the movement until it stops (inertia).
How can I do that?
I have read that I should save the last known rotation speed, and decrease that speed until 0, but I don´t know how can I implement it to my code.

(Here is the rotation code, in void Update())

  if (cameraDragging)
        {

            if (Input.GetMouseButtonDown(0))
            {
                dragOrigin = Input.mousePosition;
                return;
            }

            if (!Input.GetMouseButton(0)) return;

            Vector3 pos = Camera.main.ScreenToViewportPoint(Input.mousePosition - dragOrigin);
                Vector3 move = new Vector3(-pos.x * dragSpeed, -pos.y * dragSpeed, 0);
                    world.transform.Rotate(move.y , 0, move.x);       
        }

Thank you.

Instead of applying the mouse movement to the position directly, you need to track a velocity variable and add it to that. Then apply the velocity to the position each frame, and if the mouse is released, gradually slow down the velocity.