5031 in words is written as :

Five Thousand Thirty One