I have made an ahk script to calculate all steps a number will take to get to 1 in Collatz conjecture. It automatically begins at 1 and then goes to 2, 3, etc. The script will send each number.
Collatz conjecture is simply to choose any number. If its odd multiply by 3 and add 1, if its even then divide by 2. Repeat these steps on the number you get until you reach 1.
Wikipedia article on Collatz conjecture: https://en.wikipedia.org/wiki/Collatz_conjecture
Up arrow key runs the script.
Right arrow key opens notepad to send the numbers in.
Down arrow key to pause.
Code: Select all
Up::
Hvar := 0
Goto, Main
Main:
Svar = %Hvar%
Svar += 1
Send, Starting Variable, %Svar%
Send, {Enter}
x = %Svar%
Send, %x%{Space}
If (x & 1)
{
Goto, Odd
}
Else
{
Goto, Even
}
Even:
x /= 2
Send, %x%{Space}
If (x & 1)
{
Goto, Odd
}
Else
{
Goto, Even
}
Odd:
If (x>1)
{
x *= 3
x += 1
Send, %x%{Space}
Goto, Even
}
Else
{
Hvar += 1
Send, {Enter}
Send, {Enter}
Goto, Main
}
Down::Pause
Right::Run, Notepad.exe