Bulugh al-Maram 329
وَعَنْ أَبِي سَعِيدٍ الْخُدْرِيِّ - رضي الله عنه - قَالَ: قَالَ رَسُولُ اللَّهِ - صلى الله عليه وسلم: «إِذَا شَكَّ أَحَدُكُمْ فِي صَلَاتِهِ, فَلَمْ يَدْرِ كَمْ صَلَّى أَثْلَاثًا أَوْ أَرْبَعًا? فَلْيَطْرَحِ الشَّكَّ وَلْيَبْنِ عَلَى مَا اسْتَيْقَنَ, ثُمَّ يَسْجُدُ سَجْدَتَيْنِ قَبْلَ أَنْ يُسَلِّمَ, فَإِنْ كَانَ صَلَّى خَمْسًا شَفَعْنَ لَهُ صَلَاتَهُ, وَإِنْ كَانَ صَلَّى تَمَامًا كَانَتَا تَرْغِيمًا لِلشَّيْطَانِ». رَوَاهُ مُسْلِمٌ.
Abu Saʿid al-Khudri, may Allah be pleased with him, said: The Messenger of Allah ﷺ said: "When one of you is in doubt in his prayer and does not know how much he has prayed, three or four, let him cast aside the doubt and build on what he is certain of, then prostrate twice before giving salam. If he has prayed five, they will make his prayer even for him; and if he prayed it complete, they will be a humiliation for Shaytan." Reported by Muslim.