In higher plants, the gametes are formed by the mitotic division of microspores and megaspore. The microspores and megaspore are haploid since these are produced by the meiosis in microspore mother cell and megaspore mother cell respectively. The somatic cell has 40 chromosomes, i.e., $2n = 40.$ Then the germ cell also have 40 chromosomes. The germ cells divide by meiosis and produce four haploid (n) gametes therefore, the chromosomes number will be 20.