Skip to main content

Module collatz

Module collatz 

Source
Expand description

Collatz conjecture: sequences, stopping times, and tree visualization.

Structs§

CollatzGlyph
CollatzTree
The full reverse Collatz tree: starting from 1, build upward. Each node n has child 2n (always), and child (n-1)/3 if n ≡ 1 mod 3 and (n-1)/3 is odd and > 0.
CollatzTreeRenderer
Layout and render the Collatz tree with branch colors based on path length.
TreeNode
A node in the reverse Collatz tree.

Functions§

collatz_sequence
Compute the Collatz sequence starting from n until it reaches 1.
collatz_stopping_time
Number of steps for n to reach 1.