Let the point on z-axis be P (0,0, z).
It is equidistant from A (3, 2, 1) and B (5, 2, 5)
Using distance formula, we have
Hence, the required point is P (0, 0, 5).