Hello can anyone help me compute the sum of the first n numbers. For example n=4 => sum = 10. So far I've wrote this
    predicates
  sum(integer,integer)
clauses
  sum(0,0).
   sum(N,R):-
        N1=N-1,
        sum(N1,R1),
        R=R1+N.
This one works but I need another implementation. I don't have any ideas how I could make this differen . Please help