Since the density is proportional to the distance z from the base, the density function has the form , where k is some unknown positive constant of proportionality.

The constant k does not affect the center of gravity.

Now,

The center of gravity is on the z-axis, because