Praise be to Allah.
Deliberately praying without having purified oneself is a grave sin, and the one who does that comes under the same ruling as one who does not pray, because he has failed to do something without which his prayer is not valid.
Ibn al-Qayyim (may Allaah have mercy on him) said: The ruling on not doing wudoo’ or ghusl in the case of janaabah, and not facing the qiblah when praying, and not covering the ‘awrah, is the same as the ruling on the one who does not pray. Similarly the ruling on not standing, bowing or prostrating when one is able to do so is like the ruling on not praying. End quote from al-Salaah wa Hukm Taarikiha, p. 42.
It seems from your question that you did not do ghusl in the case of janaabah because you were unaware that it is obligatory. The scholars differed concerning one who does that – does he have to repeat the prayer or not?
If it never occurred to you that it is obligatory to do ghusl after masturbating, then we hope that you do not have to make up the previous prayers, but you have to repent and be righteous, and do a lot of good deeds. Allaah say (interpretation of the meaning):
“And verily, I am indeed forgiving to him who repents, believes (in My Oneness, and associates none in worship with Me) and does righteous good deeds, and then remains constant in doing them (till his death)”
And Allaah knows best.