0 Replies - 251 Views - Last Post: 27 March 2009 - 10:04 AM

#1 mostyfriedman   User is offline

  • The Algorithmi
  • member icon

Reputation: 729
  • View blog
  • Posts: 4,473
  • Joined: 24-October 08

factorial in prolog

Posted 27 March 2009 - 10:04 AM

Description: the predicate returns true if Y is the factorial of X
fact(0, 1).

fact(X, Y):-
	X > 0 ,X1 is X-1, fact(X1, Z), Y is X*Z.

Is This A Good Question/Topic? 0
  • +

Page 1 of 1