Narrated Ata ibn Yasar: The Prophet ﷺ said: When one of you is in doubt about his prayer, and does not know how much he has prayed, three or four rak'ahs, he should pray one (additional) rak'ah and make two prostrations while sitting before giving the salutation. If the (additional) rak'ah which he prayed is the fifth one, he will make it an even number by these two prostrations. If it is the fourth one, the two prostrations will be a disgrace for the devil.
Hadith Referenceسنن ابي داود / أبواب تفريع استفتاح الصلاة / 1026
Hadith Gradingالألبانی:صحيح | زبیر علی زئی:صحيح, وللحديث شواھد عند ابن عبد البر في التمھيد (5/20 وسنده صحيح)
Hadith Takhrij« انظر حدیث رقم : (1024)، (تحفة الأشراف: 4163، 19091) (صحیح) » (یہ حدیث بھی حدیث نمبر: (1024) کی طرح مرفوع اور متصل ہے، اس میں امام مالک نے ابو سعید خدری رضی اللہ عنہ کو جان بوجھ کر حذف کر دیا ہے جیسا کہ ان کا طریقہ ہے)
´It was narrated that Malik bin Mighwal said:` "I heard Ash-Sha'bi say: 'Alqamah bin Qais forgot (and made a mistake) in his prayer, and they told him about that after he had spoken, He said: 'Is that true, O odd-eyed one?' He said: 'Yes.' So he undid his cloak, then he performed two prostrations of forgtfulness,and said: 'This is what the Messenger of Allah (ﷺ) did.' He said: And I heard Al-Hakam say: 'Alqamah had prayed five.'"
Hafiz Muhammad Ameen
1258. Commentary: The original narration has been reported by Malik ibn Mughul from Shu’bi, in which only forgetfulness (sahw) is mentioned. There is no clarification as to what the forgetfulness was. This clarification is found in the narration of Hakam, that he (the Imam) had, out of forgetfulness, performed five rak‘ahs. Both Shu’bi and Hakam are students of ‘Alqamah.
Source: Sunan Nasa'i: Translation and Benefits by Shaykh Hafiz Muhammad Amin Hafizullah, Page: 1258