Sahih Muslim – Hadith No : 1300

Abu Sa’id al-Khudri reported: The Messenger of Allah (may peace be upon him) said: When any one of you is in doubt about his prayer and he does Dot know how much he has prayed, three or four (rak’ahs). he should cast aside his doubt and base his prayer on what he is sure of. then perform two prostrations before giving salutations. If he has prayed five rak’ahs, they will make his prayer an even number for him, and if he has prayed exactly four, they will be humiliation for the devil.

Hadith In Arabic Text :

وحدثني محمد بن أحمد بن أبي خلف، حدثنا موسى بن داود، حدثنا سليمان بن بلال، عن زيد بن أسلم، عن عطاء بن يسار، عن أبي سعيد الخدري، قال قال رسول الله صلى الله عليه وسلم ‏”‏ إذا شك أحدكم في صلاته فلم يدر كم صلى ثلاثا أم أربعا فليطرح الشك وليبن على ما استيقن ثم يسجد سجدتين قبل أن يسلم فإن كان صلى خمسا شفعن له صلاته وإن كان صلى إتماما لأربع كانتا ترغيما للشيطان ‏”‏ ‏.‏

Chapter : The Book of Mosques and Places of Prayer – كتاب الْمَسَاجِدِ وَمَوَاضِعِ الصَّلاَةِ