Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- setlocal enabledelayedexpansion
- Title GL1TCH3D Challenge Submission for Icarus Lives' Challenge
- :top
- set /p number=What positive number would you like to start with?
- set num=%number: =%
- if not %num% GTR 0 cls&goto top
- ::If your number is even, divide it by 2.
- ::If your number is odd, multiply it by 3, and add 1.
- ::Challenge ends when the script hits 1.
- ::The process to be used for determining even or odd is that batch always rounds down.
- ::A number divided by two will be compared to the original number added with 3, divided by 2 then subtracted by 1.
- ::An odd number will go up by 1 while an even number will only go up by 0 after subtracting 1.
- set step0=%num%
- set prev=%num%
- for /l %%a in (1,1,100000) do (
- set step%%a=!prev!
- set /a tempnum1=!prev! / 2
- set /a tempnum2=!prev! + 3
- set /a tempnum2=!tempnum2! / 2
- set /a tempnum2=!tempnum2! - 1
- if !tempnum1!==!tempnum2! set /a step%%a=!step%%a! / 2
- if not !tempnum1!==!tempnum2! set /a step%%a=!step%%a! * 3 + 1
- if !step%%a!==1 set total=%%a & goto end
- set prev=!step%%a!
- )
- :end
- echo Your chosen number = %number%
- echo The number of steps = %total%
- set list=%num%
- for /l %%b in (1,1,%total%) do (
- set list=!list!, !step%%b!
- )
- echo All steps = %list%
- pause > nul
Advertisement
Add Comment
Please, Sign In to add comment