‘Ata b. Yasar said that Abu Sa'id reported God’s Messenger as saying, “When one of you is in doubt aoout his prayer and does not know how much he has prayed, three or four rak'as, he should subtract what he is doubtful about and base his prayer on what he is sure of, then perform two prostrations before giving the salutation. If he has prayed five rak'as they will make his prayer an even number for him, and if he has prayed exactly four they will be a humbling for the devil.”
Muslim transmitted it, and Malik transmitted it from ‘Ata’ in mursal form. In his version it says, “he will make it an even number by these two prostrations.”
Abu Huraira reported God's Messenger as saying, “When one of you stands up to pray the devil comes to him and confuses him so that he does not know how much he has prayed. If any of you has such an experience he should perform two prostrations during the period when he sits.”*
‘Abdallah b. Mas'ud said that God’s Messenger prayed five rak'as in the noon prayer and was asked whether the prayer had been extended. He asked what they meant by that, and when they told him he had prayed five rak'as he made two prostrations after having given the salutation. In a version he said, “I am only a human being like you, foigetting just as you do; so when I forget remind me, and when any of you is in doubt about his prayer he should aim at what is correct and complete his prayer in that respect, then give the salutation and afterwards make two prostrations.”
Nafi' said that ‘Abdallah b. ‘Umar passed a man while he was praying and gave him a salutation to which the man uttered some words in reply. ‘Abdallah b. ‘Umar went back to him and said to him, “When one of you is greeted while he is engaged in prayer he must not speak, but give a sign with his hand.”