Question: who was the last ruler of magadha kingdom
Answer: Mahapadma Nanda Ugrasena ( from 345 BC ) , illegitimate son of Mahanandin , founded the Nanda Empire after inheriting Mahanandin 's empire Pandhuka Panghupati Bhutapala Rashtrapala Govishanaka Dashasidkhaka Kaivarta Dhana Nanda ( Agrammes , Xandrammes ) ( until 321 BC ) , overthrown by Chandragupta Maurya