Abu Saeed Khudri reported,

The Prophet ﷺ said, "If one of you is uncertain whether he has prayed three or four units, let him pray one more unit, then perform two prostrations afterward while seated. If he had in fact prayed five, these prostrations will make his prayer even, and if he had prayed four, they will be a humiliation for Satan."

Nasai 1240

Sahih

أخبرنا محمد بن رافع قال حدثنا حجين بن المثنى قال حدثنا عبد العزيز وهو ابن أبي سلمة عن زيد بن أسلم عن عطاء بن يسار

عن أبي سعيد الخدري

عن النبي ﷺ قال إذا لم يدر أحدكم صلى ثلاثا أم أربعا فليصل ركعة ثم يسجد بعد ذلك سجدتين وهو جالس فإن كان صلى خمسا شفعتا له صلاته وإن صلى أربعا كانتا ترغيما للشيطان

النسائي 1240صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Nasai Sughra
Book
Forgetfulness
Chapter
Completing the prayer based on what one remembers when in doubt
Numbering
Darussalam 1240
Nasai 1240