% power.pl
% pow (X,Y) finds X^Y, where Y is positive
% The warnings you get from compiling this refers to the fact that X is
% not used in the predicate = a singleton variable.
% You can get rid of the error by making it:
%      pow(_X,0) :- write(1), !.

pow(_X,0) :- write(1), !.
pow(X,1) :- write(X), !.
pow(X,N) :- pow2(X,N,X,1).   % calling a helper predicate with different # of arguments

% This is a 'helper' predicate
pow2(X,N,A,Count) :- Count >= N, write(A), !.
pow2(X,N,A,Count) :- A1 is A*X, Count1 is Count+1, pow2(X,N,A1,Count1).
