Sayyiduna Ibn Abbas (may Allah be pleased with them both) said that the Prophet (peace and blessings be upon him) would say seven takbirs over the people of Badr in the funeral prayer, and five takbirs over Banu Hashim; then, towards the end of his life (peace and blessings be upon him), the takbirs of his (peace and blessings be upon him) funeral prayer became four, until he (peace and blessings be upon him) departed from this world.
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 11314