Collatz conjecture sequence
<p>The Collatz conjecture </p>

<p>what i am trying to do:
Write a function called collatz_sequence that takes a starting integer and returns the sequence of integers, including the starting point, for that number.  Return the sequence in the form of a list.  Create your function so that if the user inputs any integer less than 1, it returns the empty list [].</p>

<p>background on collatz conjecture:</p>

<p>Take any natural number n. If n is even, divide it by 2 to get n / 2, if n is odd multiply it by 3 and add 1 to obtain 3n + 1. Repeat the process indefinitely. The conjecture is that no matter what number you start with, you will always eventually reach 1.</p>

<p>What I have so far:</p>

<pre><code>def collatz_sequence(x):
    seq = [x]
    if x &lt; 1:
       return []
    while x &gt; 1:
       if x % 2 == 0:
         x= x/2
       else:
         x= 3*x+1 
    return seq
</code></pre>

<p>When I run this with a number less than 1 i get the empty set which is right. But when i run it with a number above 1 I only get that number i.e. collatz_sequence(6) returns [6]. I need this to return the whole sequence of numbers so 6 should return 6,3,10,5,16,8,4,2,1 in a list. </p>
