The correct form is "treinta y uno", but in the spoken language, you can hear contractions as "trentidós" or "trentitrés", but the correct way to write it as separate words. This is a rule for all numbers EXCEPT with the 20's. With this series, you can write " ventiuno, ventidos, ventitrés, venticuatro, venticinco, ventiseis, ventisiete, ventiocho, ventinueve", but it is because of the ending in "e" which together with the conjunction "y" would create a very long and stressful sound ( veinte y uno), that almost nobody uses.