Click the structures and reaction arrows to view the 3D models and animations respectively
When diazomethane adds to a ketone, the product undergoes a ring expansion by rearrangement of the intermediate. Cyclohexanone is more reactive as an electrophile than either cyclopentanone or cycloheptanone, so it ring expands cleanly to cycloheptanone.
Z.-L. Song, C.-A. Fan and Y.-Q. Tu, Chem. Rev., 2011, 111, 7523–7556.