if "%1"=="" goto noarg
if "%1"=="halve" goto halve
if "%1"=="bytreeplusone" goto by3plus1
if "%1"=="evenoddchoice" goto evenoddt
if "%1"=="evenoddtest" goto evenodd2
if "%1"=="icumul" goto icumul
if "%1"=="valtostr" goto valtostr
if "%1"=="addone" goto addone
if "%1"=="moreenvmem" goto moremem
set cumul=
if "%1"=="nochoice" goto batch2
:: protection against misconfigured system
choice /? > tempch.ch
if not exist tempch.ch goto nochoice
del tempch.ch
@%comspec% /e:32768 /c %thispath% moreenvmem %1
goto fin
:moremem
shift
:: first of all , let's parse the argument
choice /c:²%1²² /t:²,1 @%thispath% nochoice > TempFil.bat
TempFil.bat
goto dltmpfin
:batch2
if exist TempFil.bat del TempFil.bat
shift
set cumul=
:2shift
shift
set result=
if "%1"=="0" set result=I
if "%1"=="1" set result=II
if "%1"=="2" set result=III
if "%1"=="3" set result=IIII
if "%1"=="4" set result=IIIII
if "%1"=="5" set result=IIIIII
if "%1"=="6" set result=IIIIIII
if "%1"=="7" set result=IIIIIIII
if "%1"=="8" set result=IIIIIIIII
if "%1"=="9" set result=IIIIIIIIII
if not "%cumul%"=="" set cumul=%cumul% %result%
if "%cumul%"=="" set cumul=%result%
if "%2"=="" goto endshift
if "%2"=="²" goto endshift
if "%2"=="²]?²" goto endshift
if not "%2"=="" goto 2shift
set cumul=%cumul%
set result=
:endshift
set result=
set loop=I
call %thispath% evenoddchoice
goto fin
if "%numtype%"=="even" call %thispath% halve %cumul%
if "%numtype%"=="odd" call %thispath% icumul %cumul%
goto evenoddt
:tendloop
set thispath=
call %thispath% valtostr inverted %loop%
echo done in %num% loops
set numtype=
set icumul=
set thispath=
set pair=
set result=
set odd=
set cumul=
set nbleft=
set nbreste=
set reverse=
set one=
set loop=
goto fin
:evenodd2
shift
if not "%2"=="" goto evenodd2
if "%1"=="I" set numtype=even
if "%1"=="II" set numtype=odd
if "%1"=="III" set numtype=even
if "%1"=="IIII" set numtype=odd
if "%1"=="IIIII" set numtype=even
if "%1"=="IIIIII" set numtype=odd
if "%1"=="IIIIIII" set numtype=even
if "%1"=="IIIIIIII" set numtype=odd
if "%1"=="IIIIIIIII" set numtype=even
if "%1"=="IIIIIIIIII" set numtype=odd
goto fin
:icumul
set icumul=
:icumul2
shift
set icumul=%1 %icumul%
if not "%2"=="" goto icumul2
call %thispath% bytreeplusone %icumul%
set icumul=
goto fin
:halve
set odd=
set pair=
set cumul=
:halvloop
shift
set result=
if "%1"=="I" set result=I
if "%1"=="III" set result=II
if "%1"=="IIIII" set result=III
if "%1"=="IIIIIII" set result=IIII
if "%1"=="IIIIIIIII" set result=IIIII
if "%1"=="II" set odd=yes
if "%1"=="II" set result=I
if "%1"=="IIII" set odd=yes
if "%1"=="IIII" set result=II
if "%1"=="IIIIII" set odd=yes
if "%1"=="IIIIII" set result=III
if "%1"=="IIIIIIII" set odd=yes
if "%1"=="IIIIIIII" set result=IIII
if "%1"=="IIIIIIIIII" set odd=yes
if "%1"=="IIIIIIIIII" set result=IIIII
if "%pair%"=="yes" set result=%result%IIIII
set pair=%odd%
set odd=
:: if "%2abcdef%result%"=="abcdefI" goto halvefin
if not "%cumul%"=="" set cumul=%cumul% %result%
if "%cumul%"=="" set cumul=%result%
if "%cumul%"=="I" set cumul=
if not "%2"=="" goto halvloop
:halvefin
set result=
set odd=
set pair=
goto fin
:by3plus1
set result=
set nbleft=I
set cumul=
:b3p1loop
shift
set nbreste=%nbleft%
set nbleft=
set result=
:: multiply by 3
if "%1"=="I" set result=I
if "%1"=="II" set result=IIII
if "%1"=="III" set result=IIIIIII
if "%1"=="IIII" set result=IIIIIIIIII
if "%1"=="IIIII" set result=III
if "%1"=="IIIII" set nbleft=I
if "%1"=="IIIIII" set result=IIIIII
if "%1"=="IIIIII" set nbleft=I
if "%1"=="IIIIIII" set result=IIIIIIIII
if "%1"=="IIIIIII" set nbleft=I
if "%1"=="IIIIIIII" set result=II
if "%1"=="IIIIIIII" set nbleft=II
if "%1"=="IIIIIIIII" set result=IIIII
if "%1"=="IIIIIIIII" set nbleft=II
if "%1"=="IIIIIIIIII" set result=IIIIIIII
if "%1"=="IIIIIIIIII" set nbleft=II
set result=%result%%nbreste%
:: rest could give an other rest
if "%result%"=="IIIIIIIIIII" set nbleft=I%nbleft%
if "%result%"=="IIIIIIIIIII" set result=I
if "%result%"=="IIIIIIIIIIII" set nbleft=I%nbleft%
if "%result%"=="IIIIIIIIIIII" set result=II
if "%result%"=="IIIIIIIIIIIII" set nbleft=I%nbleft%
if "%result%"=="IIIIIIIIIIIII" set result=III
if "%result%"=="IIIIIIIIIIIIII" set nbleft=I%nbleft%
if "%result%"=="IIIIIIIIIIIIII" set result=IIII
if "%result%"=="IIIIIIIIIIIIIII" set nbleft=I%nbleft%
if "%result%"=="IIIIIIIIIIIIIII" set result=IIIII
if "%result%"=="IIIIIIIIIIIIIIII" set nbleft=I%nbleft%
if "%result%"=="IIIIIIIIIIIIIIII" set result=IIIIII
if "%result%"=="IIIIIIIIIIIIIIIII" set nbleft=I%nbleft%
if "%result%"=="IIIIIIIIIIIIIIIII" set result=IIIIIII
if "%result%"=="IIIIIIIIIIIIIIIIII" set nbleft=I%nbleft%
if "%result%"=="IIIIIIIIIIIIIIIIII" set result=IIIIIIII
if "%result%"=="IIIIIIIIIIIIIIIIIII" set nbleft=I%nbleft%
if "%result%"=="IIIIIIIIIIIIIIIIIII" set result=IIIIIIIII
if "%result%"=="IIIIIIIIIIIIIIIIIIII" set nbleft=I%nbleft%
if "%result%"=="IIIIIIIIIIIIIIIIIIII" set result=IIIIIIIIII
if "%result%"=="IIIIIIIIIIIIIIIIIIIII" set nbleft=II%nbleft%
if "%result%"=="IIIIIIIIIIIIIIIIIIIII" set result=I
if not "%cumul%"=="" set cumul=%result% %cumul%
if "%cumul%"=="" set cumul=%result%
if not "%2"=="" goto b3p1loop
:: the result could have a larger number than expected
if "%nbleft%"=="" goto fin
set cumul=I%nbleft% %cumul%
set result=
set nbleft=
set nbreste=
goto fin
:valtostr
shift
if "%1"=="reverse" set reverse=yes
if "%1"=="reverse" shift
set num=
set result=
:valloop1
if "%1"=="I" set result=0
if "%1"=="II" set result=1
if "%1"=="III" set result=2
if "%1"=="IIII" set result=3
if "%1"=="IIIII" set result=4
if "%1"=="IIIIII" set result=5
if "%1"=="IIIIIII" set result=6
if "%1"=="IIIIIIII" set result=7
if "%1"=="IIIIIIIII" set result=8
if "%1"=="IIIIIIIIII" set result=9
if "%reverse%"=="yes" set num=%result%%num%
if not "%reverse%"=="yes" set num=%num%%result%
shift
if not "%1"=="" goto valloop1
set result=
set reverse=
goto fin
:noarg
echo look , how do you expect me to get your number ? i need a ARGUMENT to run
pause
goto fin
:nochoice
echo missing choice.com, it's surely because you on an NT machine, stupid microsoft
echo you can pick a win9x's choice.com, it must work
echo to use his batch file you will have to use the following command line :
echo %comspec% /e:32768 /c EVENODD nochoice c d u
echo exemples :
echo evenodd nochoice 1 0
echo evenodd nochoice 1 2 3
echo evenodd nochoice 2 5 6
goto fin
:addone
set loop=
set one=I
:addonel
shift
set result=%1%one%
set one=
if "%result%"=="IIIIIIIIIII" set one=I
if "%result%"=="IIIIIIIIIII" set result=I
if not "%loop%"=="" set loop=%loop% %result%
if "%loop%"=="" set loop=%result%
if not "%2"=="" goto addonel
if "%one%"=="I" set loop=%loop% II
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G
awww. just spent a whole 15 (yes 15) mins doing it in dark basic to find out someone else has done it. thatll teach me to read down the whole thread. anyway this is what i got.
x#=10
rem - number
n#=1
rem - count
while x#>1
n#=n#+1
print x# : print " ";
xtwo#=x#/2
xtre#=int(xtwo#)
if (xtre#=xtwo#)=0
x#=x#/2
else
x#=3*x#+1
endif
endwhile