A simple mathematical sequence that creates a surprisingly complex melody.

The iterator below yields a pair of values, the starting number of the sequence, and the number in each sequence.

Each integer is only visited once, to avoid too much repetition.

```
use_synth :piano
def each_collatz(n=1)
transform = ->(n){n.even? ? n/2 : 3*n+1 }
seq = n
memo = {}
loop do
memo[seq] = true
yield [n,seq]
seq = transform.(seq)
if memo[seq]
n += 1
seq = n
end
end
end
each_collatz(300) do |n,seq|
puts "start number:#{n}, sequence:#{seq}"
play 4*Math.log(seq,2)+32
sleep 0.12
end
```