<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=windows-1252">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello, <br>
    <br>
    I changed my code so that it also can count from a number to a
    number, so sum(3,6) does 3+4+5+6 and sum(2) does 0+1+2 <br>
    <br>
    I now have this : <br>
    <br>
    -module(sum_recursion).<br>
    <br>
    -export([sum/1, sum/2]).<br>
    <br>
    % when the number is zero the outcome will also be zero<br>
    sum(0) -><br>
      0; <br>
    <br>
    % when a number is greater then 0 , call the helper function.<br>
    sum(End) when End > 0 -> <br>
      sum_acc(End,0);<br>
    <br>
    % when the first number is greater then zero and lower then the
    second number<br>
    sum(Begin, End) when Begin >= 0 , Begin =< End -><br>
      sum_acc(Begin, End, Begin).<br>
                   <br>
    % When End is equal to zero all the numbers are added<br>
    sum_acc(0,Acc) -><br>
         Acc;<br>
    <br>
    % When End is equal to Begin all numbers are added. <br>
    sum_acc(Begin, Begin, Acc) -><br>
      Acc ; <br>
    <br>
    % when end is not zero there are more numbers to be added. <br>
    sum_acc(End, Acc) -><br>
         sum_acc(End - 1, Acc + End);  <br>
    <br>
    % When end is not equal to begin then there are more numbers to be
    added. <br>
    sum_acc(Begin, End, Acc) -><br>
      sum_acc(Begin, End - 1, Acc + End).<br>
     <br>
    <br>
    but as soon as I try to compile it I see this error : <br>
    <br>
    <input class="terminal-input">
    <div data-row="1" class="terminal-row">error                                                                                                                                                                                  </div>
    <div data-row="2" class="terminal-row">7> c(sum_recursion).                                                                                                                                                                   </div>
    <div data-row="3" class="terminal-row">sum_recursion.erl:14: head mismatch                                                                                                                                                    </div>
    <div data-row="4" class="terminal-row">sum_recursion.erl:22: head mismatch                                                                                                                                                    </div>
    <div data-row="5" class="terminal-row">sum_recursion.erl:3: function sum/1 undefined                                                                                                                                          </div>
    sum_recursion.erl:3: function sum/2 undefined <br>
    <br>
    Am I not alllowed to do this <br>
    <br>
    sum(x) -> <br>
       x ; <br>
    <br>
    sum(x,y) -><br>
      x + y.   <br>
    <br>
    or is there something else missing ?<br>
    <br>
    Roelof<br>
    <br>
  </body>
</html>