[Machine] The Messenger of Allah ﷺ said: "If anyone of you has doubts about his prayer, he should not know how many times he prayed three or four (rak'ahs). He should stand up and pray a rak'ah, then prostrate twice while sitting before the salutation. If the rak'ah he prayed was the fifth, he should make up for it with these two prostrations. If it was the fourth, then the two prostrations are a deterrent for Satan, except that Hisham reported to Abu Sa'eed al-Khudri that it is done like this."
أَنَّ رَسُولَ اللهِ ﷺ قَالَ إِذَا شَكَّ أَحَدُكُمْ فِي الصَّلَاةِ فَلَا يَدْرِي كَمْ صَلَّى ثَلَاثًا أَوْ أَرْبَعًا فَلْيَقُمْ فَلْيُصَلِّ رَكْعَةً ثُمَّ لِيَسْجُدْ سَجْدَتَيْنِ وَهُوَ جَالِسٌ قَبْلَ السَّلَامِ فَإِنْ كَانَتِ الرَّكْعَةُ الَّتِي صَلَّى خَامِسَةً شَفَعَهَا بِهَاتَيْنِ السَّجْدَتَيْنِ وَإِنْ كَانَتْ رَابِعَةً فَالسَّجْدَتَانِ تَرْغِيمٌ لِلشَّيْطَانِ إِلَّا أَنَّ هِشَامًا بَلَغَ بِهِ أَبَا سَعِيدٍ الْخُدْرِيِّ هَكَذَا