@ECHO OFF
SETLOCAL
SET X=10
CALL :Fib %X% Y
ECHO Fib^(%X%^)=%Y%
GOTO :EOF
:Fib [In]X [Out]Result
SETLOCAL
SET A=%1
SET D=1
SET E=0
IF %A% LEQ 1 (
GOTO FibRet
)
SET /A B=%A%-1
SET /A C=%A%-2
CALL :Fib %B% D
CALL :Fib %C% E
:FibRet
ENDLOCAL SET /A %2=%D%+%E% GOTO :EOF