The number 31987 (thirty-one thousand nine hundred eighty-seven) is written in Roman numerals as follows: XXXICMLXXXVII