Q factor is defined as the ratio of the total amount of energy stored in the pendulum and total amount of energy lost per one cycle.

We will need to figure out power loss and energy stored.
Power loss is happening due to friction. It is equal to power that the weight is supplying to the clock:

Now we need to figure out the energy stored in one the pendulum. We can think of this as potential energy of the pendulum:


Please see the attachment for clarification.
Now we can calculate the Q factor:
