The Messenger of Allah ﷺ said, "When one of you is uncertain about his prayer and does not know how many units he has prayed, three or four, he should cast aside the doubt and build upon what he is certain of. Then let him perform two prostrations before giving the closing salutation. If he had actually prayed five units, these prostrations will make his prayer an even number for him, and if he had completed four units, the two prostrations will be a humiliation for Satan."
و حدثني محمد بن أحمد بن أبي خلف حدثنا موسى بن داود حدثنا سليمان بن بلال عن زيد بن أسلم عن عطاء بن يسار
قال رسول الله ﷺ إذا شك أحدكم في صلاته فلم يدر كم صلى ثلاثا أم أربعا فليطرح الشك وليبن على ما استيقن ثم يسجد سجدتين قبل أن يسلم فإن كان صلى خمسا شفعن له صلاته وإن كان صلى إتماما لأربع كانتا ترغيما للشيطان