AceInfinity
Emeritus, Contributor
lol :hysterical:
Here's a recursive script I came up with earlier. It was fun, I got to see this message for a while until I fixed out the bugs in my script:
Sad thing is, because batch only supports 32 bit integers as far as I know, the maximum it can calculate up to is 12!. 0! to 12! will yield all accurate results.... Anything past that is too larger for a 32 bit integer; almighty batch scripting. :thumbsup2:
Code:
@echo off
setlocal enabledelayedexpansion
for /l %%G in (0,1,12) do (
set /a n=%%G
) & call :Factorial !n! & echo %%G^^! = !_Factorial!
pause & goto :eof
:Factorial
set _Factorial=1
call :calc_factorial %1 & goto :eof
:calc_factorial
set /a num=%1
if %num% gtr 1 (
set /a _Factorial*=!num!
call :calc_factorial !num!-1
)
goto :eof
Here's a recursive script I came up with earlier. It was fun, I got to see this message for a while until I fixed out the bugs in my script:
Code:
** B A T C H R E C U R S I O N exceeds STACK limits **
Recursion Count=394, Stack Usage=90 percent
** B A T C H PROCESSING IS A B O R T E D **
Sad thing is, because batch only supports 32 bit integers as far as I know, the maximum it can calculate up to is 12!. 0! to 12! will yield all accurate results.... Anything past that is too larger for a 32 bit integer; almighty batch scripting. :thumbsup2: