WAP
to compute factorial of a number.
predicates
factorial(integer,real)
go
clauses
go:-
write("Type
a Positive integer Number \n"),
readint(N),
factorial(N,Result),
write("The
factorial of ",N,"is = ",Result).
factorial(0,1).
factorial(N,Result)
if N>0,
N1=N-1,
factorial(N1,Resl),
Result=N*Resl.
Output:-
Goal:
go
Enter
a positive integer number:5
The
factorial of 5 is 120
Goal:
go
Enter
a positive integer number:3
The
factorial of 3 is 6
Goal:go
Enter
a positive integer number:0
The
factorial of 0 is 1