title: Finding the longest collatz sequence for any number under 100
body: <pre><code>def longest_collatz_sequence(n)
      longest_sequence = []
      (1..n).each do |a|
          sequence = [a]
          until sequence.last == 1
              if a % 2 == 0
                  sequence.push(a/2)
              else
                  sequence.push(3 * a + 1)
              end
          end
          if sequence.length &gt; longest_sequence.length
              longest_sequence = sequence
          end
      end
      longest_sequence
  end
  </code></pre>
  
  <p>longest_collatz_sequence(n) works for n = 2, but doesn't work for n > 2. What am I doing wrong?
  Thanks!</p>