The second view (1) on this issue is that if a person doubts and one of the two possibilities appears more likely to him, he should act upon what seems more likely, whether it is the greater or the lesser number.
The evidence for this view is the hadith of Ibn Masʿūd, may Allah be pleased with him: concerning one who doubts and is uncertain whether he prayed three or four rakʿahs, the Prophet ﷺ said: “...Let him seek what is correct and complete his prayer accordingly”—that is, he should base it on what he judges more likely—“then let him say the salām, and then prostrate twice.” (2)
Together with the first hadith, this indicates that the person in doubt is in one of two states:
The first is a state in which he can determine what is more likely, namely, when one of the two possibilities outweighs the other in his estimation.
The second is a state in which he cannot determine what is more likely, namely, when there is doubt without either possibility being given greater weight.
Accordingly, we say: if he doubts the number of rakʿahs, and one of the two possibilities seems more likely to him, he acts upon it and bases his prayer on it, then performs two prostrations after the salām. But if neither possibility seems more likely to him, he takes the lesser number and bases his prayer upon it, then performs the prostration before the salām.
For example, a man prays and doubts whether he prayed three or four rakʿahs, but it seems more likely to him that he prayed four. We say: Count it as four, since that is what appears more likely to you; then say the salām, and then perform two prostrations after the salām.
If it seems more likely to him that he prayed three, he counts it as three, completes what remains, and performs two prostrations after the salām.