Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
23
Task/Hailstone-sequence/Batch-File/hailstone-sequence-2.bat
Normal file
23
Task/Hailstone-sequence/Batch-File/hailstone-sequence-2.bat
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
@echo off
|
||||
setlocal enableDelayedExpansion
|
||||
if "%~1"=="test" (
|
||||
for /l %%. in () do (
|
||||
set /a "test1=num %% 2, cnt=cnt+1"
|
||||
if !test1! equ 0 (set /a num/=2 & if !num! equ 1 exit !cnt!) else (set /a num=3*num+1)
|
||||
)
|
||||
)
|
||||
|
||||
set max=0
|
||||
set record=0
|
||||
|
||||
for /l %%X in (2,1,100000) do (
|
||||
set num=%%X & cmd /c "%~f0" test
|
||||
if !errorlevel! gtr !max! (set /a "max=!errorlevel!,record=%%X")
|
||||
)
|
||||
set /a max+=1
|
||||
|
||||
echo.Number less than 100000 with longest sequence: %record%
|
||||
echo.With length %max%.
|
||||
pause>nul
|
||||
|
||||
exit /b 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue