@echo off
pause
set /a x=1
set /a n=0
set /p x_end=x (End)=
:loop
cls
set /a n=n+1
set /a x=x+n+1
set /a students=n+2
echo x=%x%, n=%n%, x (End)=%x_end%
if (%x%=%x_end% goto end)
goto loop
:end
echo Answer: x (End)=%x%, Students=%students%, n (end)=%n%
echo.
echo Click Anything To Exit...
pause > nul
exit
The "if" line is producing a message that what you put in the %x_end% variable "was unexpected this time".
goto
.