CODE: [Copy to clipboard]
@echo off
setlocal enabledelayedexpansion
::::::::::::::::::::::::::::Find The Biggest Public Divisor::::::::::::::::::::::::::::
:::::::::::::::::::::::::::: {s11ss 2007-9-21} ::::::::::::::::::::::::::::
:r
echo Please input two integers,like 9,21:
set /p n=
echo.
echo Calculating...
set /a i=1
for %%a in (!n!) do (
set n!i!=%%a
set /a i+=1
)
if !n1! equ !n2! (
call :e !n1!
goto :eof
)
if !n1! lss !n2! (
set t=!n1!
set n1=!n2!
set n2=!t!
)
set /a big=!n1!
set /a small=!n2!
:c
set /a remain=!big!%%!small!
if !remain! equ 1 (
echo.
echo They don't have the public divisor.
goto :e
)
if !remain! equ 0 (
echo.
echo The biggest public divisor is !small!.
goto :e
) else (
set big=!small!
set small=!remain!
goto :c
)
:e
echo.
echo Press Any Key To Exit...
pause>nul