Numbers in spanish follow a pattern after the number 15:
Tens place word y ones place word
These words are spelled as one word from 16-29 (i.e. 17 = diecisiete, 25 = veinticinco)
After 29, however, they are written as separate words (i.e. 42 = cuarenta y dos)