40039 in words is written as :

Forty Thousand Thirty Nine