So to correct a clock that is running a little fast,
we wish to increase T. Hence we increase l a little.
If the length of the pendulum is doubled,
l is replaced by 2l.
This means that T is increased by a factor of 2.
Similarly, if l is halved, T is decreased;
the new value is T /2.
In the formula we notice that the
period T is inversely proportional to the gravity g.
This means that for a given, fixed length l,
T increases when g decreases.
So if T is to remain the same when the clock
is on the moon, the length l will also
have to be decreased,
and in fact proportionally to the change in gravity.