Exactly what's the prolog definition for power function. I wrote this code and it give some errors I wanna know exact code for the power function.
pow(X,0,1).
pow(X,Y,Z):-Y1=Y-1,pow(X,Y1,Z1),Z1=Z*X.
Anything wrong with this code?
Exactly what's the prolog definition for power function. I wrote this code and it give some errors I wanna know exact code for the power function.
pow(X,0,1).
pow(X,Y,Z):-Y1=Y-1,pow(X,Y1,Z1),Z1=Z*X.
Anything wrong with this code?
Have a look here - http://stackoverflow.com/questions/1448790/power-function-in-prolog. The built-in pow predicate is not implemented in prolog for efficiency reason - as most arithmetic predicates.