• Uncategorized

Prolog program to find Factorial of an Integer

PREDICATES
factorial(integer, integer)

CLAUSES
factorial(0,1).
factorial(X,Y):-
X<>0, S=X-1, factorial(S,Y1), Y=X*Y1.

GOAL
write(“The value of Z is “),
factorial(5,Z).

SHARE Prolog program to find Factorial of an Integer

You may also like...

1 Response

  1. Unknown says:

    compiling /home/jdoodle.pg for byte code…
    /home/jdoodle.pg:2:1: syntax error: . or operator expected after expression
    /home/jdoodle.pg:7:2: syntax error: . or operator expected after expression
    /home/jdoodle.pg:10:1: syntax error: . or operator expected after expression
    3 error(s)
    compilation failed
    | ?-
    uncaught exception: error(syntax_error('user_input:4 (char:1) . or operator expected after expression'),read_term/3)
    | ?-


Warning: Undefined array key 0 in /www/wwwroot/followtutorials.com/wp-content/themes/hueman/single.php on line 9

Warning: Attempt to read property "cat_name" on null in /www/wwwroot/followtutorials.com/wp-content/themes/hueman/single.php on line 9

Warning: Undefined array key 0 in /www/wwwroot/followtutorials.com/wp-content/themes/hueman/single.php on line 14

Warning: Attempt to read property "category_parent" on null in /www/wwwroot/followtutorials.com/wp-content/themes/hueman/functions.php on line 37

Warning: Undefined array key 0 in /www/wwwroot/followtutorials.com/wp-content/themes/hueman/single.php on line 15

Warning: Attempt to read property "category_parent" on null in /www/wwwroot/followtutorials.com/wp-content/themes/hueman/single.php on line 15
Share