The last verse revealed was "They ask you for a ruling. Say, Allah gives you a ruling concerning those who leave no descendants or ascendants as heirs" [Nisa 4:176], and the last surah revealed was Baraah.
آخر آية نزلت: {يستفتونك قل الله يفتيكم في الكللة} [سورة النساء: ١٧٦]، وآخر سورة نزلت براءة.
Bukhari related it in the tafsir (4654), and Muslim in the inheritance shares (11:1618), both through Shubah, from Abu Ishaq, who said, I heard Bara bin Azib say, and he mentioned it.