Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ::---------------------------------------------------------------------------------------
- :: Get the factorial of a number
- ::
- :: call :factorial 7 RETURNVAR
- :: echo %RETURNVAR%
- ::---------------------------------------------------------------------------------------
- :factorial
- setlocal
- set "out=1"
- for /l %%a in (%~1,-1,1) do set /a "out*=%%a"
- if %~1 equ 0 set "out=1"
- (endlocal
- if "%~2" neq "" ( set "%~2=%out%" ) else echo %out%
- )
- goto :eof
- ::---------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement