You haven't ended theif /else /end statement you started withif mod(n,2) == 0. If you put this code in the Editor, select all the code, right click, and select Smart Indent in the context menu you'll see that theif on line 5 lines up with theelse on line 32, but there's no correspondingend.
FYI you probably don't want to callexit on line 33; that would quit MATLAB altogether.
Best Answer