أَخْبَرَنَا مُحَمَّدُ بْنُ رَافِعٍ، قَالَ حَدَّثَنَا حُجَيْنُ بْنُ الْمُثَنَّى، قَالَ حَدَّثَنَا عَبْدُ الْعَزِيزِ، - وَهُوَ ابْنُ أَبِي سَلَمَةَ - عَنْ زَيْدِ بْنِ أَسْلَمَ، عَنْ عَطَاءِ بْنِ يَسَارٍ، عَنْ أَبِي سَعِيدٍ الْخُدْرِيِّ، عَنِ النَّبِيِّ صلى الله عليه وسلم قَالَ ‏"‏ إِذَا لَمْ يَدْرِ أَحَدُكُمْ صَلَّى ثَلاَثًا أَمْ أَرْبَعًا فَلْيُصَلِّ رَكْعَةً ثُمَّ يَسْجُدْ بَعْدَ ذَلِكَ سَجْدَتَيْنِ وَهُوَ جَالِسٌ فَإِنْ كَانَ صَلَّى خَمْسًا شَفَعَتَا لَهُ صَلاَتَهُ وَإِنْ صَلَّى أَرْبَعًا كَانَتَا تَرْغِيمًا لِلشَّيْطَانِ ‏"‏ ‏.‏

It was narrated from Abu Sa'eed Al-Khudri that: The Prophet (PBUH) said: "If one of you does not know whether he prayed three or four (rak'ahs), let him pray a rak'ah then prostrate twice after that when he is sitting. Then if he prayed five (rak'ahs), they (the two prostrations) will make his prayer even-numbered, and if he had prayed four, they will annoy and humiliate the shaitan." Translation Not Available

Book Ref: Sunan An Nisai Book 13 Hadith 1239
Web Ref:  Sunan An Nisai Vol 2 Book 13 Hadith 1240