predicates
power(integer,integer,real)
go
clauses
go:-write("Enter
the base and the exponent"), readint(X),readint(Y),
power(X,Y,A),
write("\nThe
answer is ",A).
power(X,0,1).
power(X,Y,A)
if X>0,
Y1=Y-1,
power(X,Y1,A1),
A=A1*X.
Output:-
Goal:go
Enter
the base and the exponent 2 3
The
answer is 8 Yes
Goal:go
Enter
the base and the exponent 4 0
The
answer is 1 Yes