Abdul-Rahman bin Awf reported,

I heard the Prophet ﷺ say, "When one of you becomes uncertain during his prayer and does not know whether he has prayed one rakah or two, let him assume it was one. If he does not know whether he has prayed two or three, let him assume it was two. If he does not know whether he has prayed three or four, let him assume it was three. Then let him perform two prostrations before giving the salam."

Tirmidhi 398

Hasan

حدثنا محمد بن بشار حدثنا محمد بن خالد ابن عثمة البصري حدثنا إبراهيم بن سعد قال حدثني محمد بن إسحق عن مكحول عن كريب عن ابن عباس

عن عبد الرحمن بن عوف قال

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

الترمذي 398حسن
Contents
Reference
Commentary
Ayat
Collection
Jami Tirmidhi
Book
Prayer
Chapter
Man who prays and is uncertain about addition or omission
Numbering
Darussalam 398
Tirmidhi 398