Ata bin Yasar (may Allah have mercy on him) said: I asked Abdullah bin Amr bin al-As (may Allah be pleased with them both) and Ka'b al-Ahbar (may Allah have mercy on him) about a person who has a doubt in his prayer and does not know how many rak'ahs he has prayed, three or four. Both of them said: He should stand up and pray one more rak'ah, and perform two prostrations when he has prayed it.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3812