I am currently trying to write a batch file for a project that will mimic the structure of the following pseudocode:
void h ( int n )
if ( n ≥ 4 )
h ( n / 2 )
end if
print n
end h
And generate the following output:
2
4
8
16
When the function is given 16 as input.
This is the closest I've come so far:
@ECHO off
SET /A number=%1
IF %number% GEQ 4 (
CALL recursive-36 number/2
REM The following line returns 4, 8, 16.
REM ECHO %number%
)
REM The following line returns 2, 2, 2, 2.
ECHO %number%
No matter where I put the ECHO %number% statement, however, I can't get 2, 4, 8, 16 as output. Why is that? Is this a pass-by-reference thing? Or is there something else I'm missing?
IF %number% GEQ 4 (
which means if number is greater or equal to 4. That is why it never does a 2. Isn't it enough to change that toGEQ 2
?