:-object sum1.

var  i := 100.

main :- sum(i, S),
             format('the sum from 1 to ~w is ~w~n', [i, S]).


sum(1,1).

sum(N,S):- N1 is N-1,
	     sum(N1,S1),
	     S is S1+N.


:-end_object sum1.