The evolution of the galaxy mass function MF (and luminosity function LF) depending on merging of galaxies is discussed. The richness and masses of most massive (and most luminous) galaxies of a cluster are chosen as a characteristic of the bright edge of LF. Mergers are simulated by a Monte-Carlo method. The probability of merging depends on the masses of galaxies. The ratio of the current number of galaxies to the initial one plays the role of the time scale. Transformation to real time and redshift is realized with help of the Smoluchowsky kinetic equation (SE) solution, describing the merging process and making possible to find the dependence of the galaxy number on time. The dependencies of richness, masses and magnitude differences of most massive and brightest galaxies of a cluster on redshift have been obtained. Creation of cD-galaxy has been retraced on small redshifts. The masses of the second and less massive cluster galaxies grow, but after the creation of the cD-galaxy they begin to decrease. Comparison of obtained results with data of the catalogues is provided. Correspondence in mentioned dependencies is observed.