Featured Post

Step Wise Project Planning

Planning is the most difficult process in project management. The framework described is called the Stepwise method to help to distinguis...

  1. Home

Write a program to compute the result of an exponent


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
Previous
Next Post »