Ata bin Yasar reported,

The Messenger of Allah ﷺ said, "If one of you is uncertain during his prayer and does not know how much he has prayed, whether three or four, let him pray one rakat and then perform two prostrations while seated, before giving the greeting of peace. If the rakat he prayed turns out to be a fifth, these two prostrations make it an even number, and if it was the fourth, then the two prostrations are a humiliation for Satan."

Malik 218

Sahih

حدثني يحيى عن مالك عن زيد بن أسلم

عن عطاء بن يسار

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

مالك 218صحيح
Contents
Reference
Commentary
Ayat
Collection
Muwatta Malik
Book
Prayer
Numbering
Laithi 218
Malik 218