Build a self-running pixel matrix in Minecraft Java Edition that computes and illuminates the Collatz mathematical number sequence in real time.
Signs & BillboardsTechnologyBlackCyanPinkLearningDecorationText displaysBlock building (fill/setblock/clone)21+ commands
Watch a giant obsidian display screen come to life as a glowing scanner calculates and plots the famous Collatz 3n+1 sequence block by block. A floating readout above the frame tracks the live mathematical values while the matrix fills with colorful glowing pixels.
Each pixel represents a step in the trajectory: cyan sea lanterns mark numbers multiplying up (3n+1), while purple froglights mark numbers dividing down (n/2). When the screen fills up, it automatically wipes clean and continues the endless pattern.
/scoreboard objectives add c9_math dummy/scoreboard players set #n c9_math 27/scoreboard players set #x c9_math -8/scoreboard players set #y c9_math 2/scoreboard players set #two c9_math 2/scoreboard players set #three c9_math 3/fill ~-9 ~1 ~ ~9 ~16 ~ polished_blackstone_bricks/fill ~-8 ~2 ~ ~8 ~15 ~ black_concrete/summon marker ~-8 ~2 ~ {Tags:["c9_cursor","c9_ent"]}/summon text_display ~ ~17 ~-0.5 {Tags:["c9_ent","c9_hud"],billboard:"center",background:1073741824,transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],scale:[2.2f,2.2f,2.2f],translation:[0f,0f,0f]},text:{"text":"Collatz Sequence Matrix","color":"aqua"}}/scoreboard players add #tick c9_math 1/execute if score #tick c9_math matches 2.. run scoreboard players set #tick c9_math 0/execute if score #tick c9_math matches 1 run scoreboard players operation #mod c9_math = #n c9_math/execute if score #tick c9_math matches 1 run scoreboard players operation #mod c9_math %= #two c9_math/execute if score #tick c9_math matches 1 if score #mod c9_math matches 0 run scoreboard players operation #n c9_math /= #two c9_math/execute if score #tick c9_math matches 1 if score #mod c9_math matches 1 run scoreboard players operation #n c9_math *= #three c9_math/execute if score #tick c9_math matches 1 if score #mod c9_math matches 1 run scoreboard players add #n c9_math 1/execute if score #tick c9_math matches 1 if score #n c9_math matches ..1 run scoreboard players add #seed c9_math 7/execute if score #tick c9_math matches 1 if score #n c9_math matches ..1 run scoreboard players operation #n c9_math += #seed c9_math/execute if score #tick c9_math matches 1 at @e[tag=c9_cursor] if score #mod c9_math matches 1 run setblock ~ ~ ~ sea_lantern/execute if score #tick c9_math matches 1 at @e[tag=c9_cursor] if score #mod c9_math matches 0 run setblock ~ ~ ~ pearlescent_froglight/execute if score #tick c9_math matches 1 at @e[tag=c9_cursor] run particle firework ~ ~0.5 ~-0.6 0.1 0.1 0.1 0.05 5 force/execute if score #tick c9_math matches 1 as @e[tag=c9_cursor] at @s run tp @s ~1 ~ ~/execute if score #tick c9_math matches 1 at @e[tag=c9_cursor] if block ~ ~ ~ polished_blackstone_bricks run tp @e[tag=c9_cursor] ~-17 ~1 ~setup #2 Starts the sequence at 27, a classic number in the Collatz conjecture known for taking 111 steps and climbing to 9,232 before reaching 1.loop #4 Copies the current number into #mod and uses modulo 2 (%= #two) to check if the current value is even (0) or odd (1).loop #6 If the number is odd (#mod matches 1), multiplies it by 3 and adds 1 in the next command. If it was even, the previous command divided it by 2.loop #10 Places a glowing cyan sea lantern at the cursor position when the sequence steps upward, or a purple pearlescent froglight in the next command when stepping downward.loop #14 When the cursor hits the right border of polished blackstone bricks, it wraps back 17 blocks to the left and moves up 1 row.


Recorded on our own test server: 60 frames at about 9.9 fps. Our image check saw: A large black screen framed in dark stone bricks progressively fills row by row from the bottom up with alternating sea lanterns and pearlescent froglights at night, though the mentioned floating readout above the frame is barely visible or cut off.
Commands, video and screenshots: tested and recorded by www.9minecraft.net © 9Minecraft. Sharing a video or screenshot? Please credit www.9minecraft.net.
To let players input their own starting seed number, place an impulse command block with a button that runs /scoreboard players set #n c9_math 73 (or any positive integer) and /fill ~-8 ~2 ~ ~8 ~15 ~ black_concrete to reset the canvas.
/kill @e[tag=c9_ent]/fill ~-9 ~1 ~ ~9 ~17 ~ air/scoreboard objectives remove c9_mathCyan sea lanterns indicate an odd number that multiplied up (3n+1), while purple pearlescent froglights indicate an even number that divided in half (n/2).
In the second loop command, change matches 2.. to matches 1.. so the screen calculates and plots a new pixel every single game tick (20 pixels per second).
▶2D Arcade Dino RunnerSigns & BillboardsHard25 cmds
▶Animated Block Broadcast ScreenSigns & BillboardsHard24 cmds
▶Animated Flat-Screen TelevisionSigns & BillboardsHard24 cmds
▶Auto-Playing Desert Dino RunnerSigns & BillboardsHard21 cmds
▶Block-Cloned Cinema ScreenSigns & BillboardsMedium24 cmds
▶Blockbuster Drive-In TheaterSigns & BillboardsExpert24 cmds