% Some examples of recursive clauses

:- solve(range(0,100,List)).
:- solve(for(I,0,150)).
:- solve(test_factorial(15,I,Result)).

for(From,From,From) :- !.
for(From,From,To) :-
	From<=To.
for(I,From,To) :-
	From2=From+1,
	for(I,From2,To).

test_factorial(M,I,Result) :-
	for(I,0,M),
	factorial(I,Result).

factorial(0,1). 
factorial(N,F) :-  
   N>0, 
   N1=N-1, 
   factorial(N1,F1), 
   F=N*F1.

range(N,N,[N]) :- !.
range(M,N,[M|Ns]) :-
	M < N,
	M1=M+1,
	range(M1,N,Ns).
