;??-Jun-1999                                                    Alain Brobecker
;Recursively compute 1+2+...+n = n*(n+1)/2

 256 Sum
 "1+2+3+...255+256 = " HPRINT CR
 128 257 *
 "256*(256+1)/2 = " HPRINT CR
END

#Sum
  COPY                  ;n n
  1 -                   ;n (n-1)
  COPY                  ;n (n-1) (n-1)
  SKIP<>0 SumEnd        ;If n=1 then go to SumEnd
  Sum                   ;Else compute 1+...+(n-1)
  +                     ;  and 1+...+n = 1+...+(n-1)+n
END

.SumEnd DROP END
