title: Collatz sequence in Erlang
body: <p>The problem that I am trying to solve is as follows:
  Write an Erlang function named collatz that takes one argument N. You may assume that N is an integer 1 or larger. The function should print the Collatz sequence (one number per line) starting with N. For example, collatz( 4 ) should print 4, 2, 1 (on separate lines). collatz( 6 ) should print 6, 3, 10, 5, 16, 8, 4, 2, 1 (on separate lines).</p>
  <p>The collatz function that I have written is working properly but I am having difficulty in printing the output on separate lines. The commented-out part of the code below is my attempt to generate the output on separate lines.</p>
  <pre><code>    collatz(1) -&gt; [1];
      collatz(N) when N rem 2 == 0 -&gt;
      [N|collatz(N div 2)];
      %[io:format(&quot;Collatz is : ~p~n&quot;,[N])N|collatz(N div 2)];
      collatz(N) -&gt;
      [N|collatz(3*N+1)].
      %[io:format(&quot;Collatz is : ~p~n&quot;,[N])N|colla[N|collatz(N div 2)]tz(3*N+1)].
      
  </code></pre>
  <p>The output that I get when I call for example collatz(5) is [5,16,8,4,2,1]. I want these numbers to be printed out on separate lines.</p>