Overview
The Collatz Conjecture Explorer allows you to test the Collatz conjecture (3n+1 problem) using Romasm assembly with BigInt support for numbers beyond JavaScript's safe integer limit.
The Collatz Conjecture
What is it?
Start with any positive integer n. Then repeatedly apply:
- If n is even: n → n/2
- If n is odd: n → 3n + 1
The conjecture states that every starting number eventually reaches 1, regardless of how large it is.
Status: Unproven, but verified up to ~2^71 (as of 2025).
Romasm Implementation
The explorer uses Romasm assembly to compute Collatz sequences:
; Collatz sequence in Romasm
LOAD R1, 1 ; Constant 1
LOAD R2, 2 ; Constant 2
LOAD R3, 3 ; Constant 3
loop:
CMP R0, R1 ; Check if current number is 1
JEQ done ; If 1, we're done
PRINT R0 ; Print current number
; Check if even (R0 % 2 == 0)
LOAD R4, R0
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
BigInt Support
For numbers beyond JavaScript's safe integer limit (2^53), the explorer uses BigInt arithmetic:
- Numbers are stored as strings
- Operations are performed digit-by-digit
- Allows testing numbers with hundreds of digits
Using the Explorer
- Enter a starting number (can be very large)
- Click "Run Collatz Sequence"
- View the sequence as it's computed
- See the total number of steps to reach 1
Related Documentation
- Big Integer Support - How BigInt works
- Try the Explorer - Open it now!