9871 in words is written as :

Nine Thousand Eight Hundred and Seventy One