The number 31871 (thirty-one thousand eight hundred seventy-one) is written in Roman numerals as follows: XXXIDCCCLXXI