About the Collatz Conjecture
The Problem
Start with any positive integer n. If n is even, divide by 2. If n is odd, multiply by 3 and add 1. Repeat. The conjecture states that all sequences eventually reach 1.
The Rules
- If n is even: n → n/2
- If n is odd: n → 3n + 1
- Repeat until n = 1
Status
This is one of the most famous unsolved problems in mathematics. No counterexample has been found, but it hasn't been proven for all numbers.
Big Integer Support
This explorer uses Big Integer arithmetic to handle arbitrarily large numbers, bypassing JavaScript's floating-point limits. You can test numbers with hundreds or thousands of digits!
Run Collatz Sequence
💡 Try a huge number! Numbers with 15+ digits automatically use Big Integer arithmetic.
Romasm Implementation
; Collatz Conjecture in Romasm
; Input: Starting number in R0
; Output: Sequence printed to console
LOAD R1, 1 ; Constant 1
LOAD R2, 2 ; Constant 2 for modulo
LOAD R3, 3 ; Constant 3 for multiplication
LOAD R5, 1 ; Shift amount for SHR
loop:
; Check if current number is 1
CMP R0, R1
JEQ done
; Print current number
PRINT R0
; Check if even (R0 % 2 == 0)
LOAD R4, R0 ; Copy R0 to R4
MOD R4, R2 ; R4 = R0 % 2
CMP R4, R1 ; Compare with 1
JEQ is_odd ; If R4 == 1, it's odd
; Even: divide by 2
SHR R0, R1 ; R0 = R0 >> 1 (divide by 2)
JMP loop
is_odd:
; Odd: multiply by 3 and add 1
MUL R0, R3 ; R0 = R0 * 3
ADD R0, R1 ; R0 = R0 + 1
JMP loop
done:
PRINT R1 ; Print final 1
Results
Click "Run Collatz Sequence" to see results...
-
Steps
-
Peak Value
-
Odd Steps
-
Even Steps