Alqamah (may Allah have mercy on him) said: I said to Sayyiduna Abdullah bin Mas'ud (may Allah be pleased with him): "The companions of Mu'adh (may Allah be pleased with him) came from Syria and said five takbirs over one of their dead." Sayyiduna Abdullah bin Mas'ud (may Allah be pleased with him) said: "There is no fixed number of takbirs over the deceased; say as many takbirs as the imam says, and when the imam finishes, finish as well."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الجنائز / 6945