The Messenger of Allah ﷺ said, "When one of you prays and does not know how many units he has prayed, three or four, let him perform one more unit, doing its bowing and prostration well, and then perform two prostrations."
قال رسول الله ﷺ: إذا صلى أحدكم فلا يدري كم صلى، ثلاثا أو أربعا، فليركع ركعة، يحسن ركوعها وسجودها، ويسجد سجدتين.
Ibn Khuzayma (1026) and Hakim (1/322, 260) both narrated it through the hadith of Ayub bin Sulayman bin Bilal, who said, Abu Bakr bin Abu Uways told me, from Sulayman bin Bilal, from Umar bin Muhammad bin Zayd, from Salim bin Abdullah, from Abdullah bin Umar, mentioning the same. Hakim said, "It is sahih according to the standard of the two Shaykhs, but they did not include it with this addition mentioning the fourth."