-->

Prolog program to find Factorial of an Integer

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).

    fardi zayden
    @مرسلة بواسطة
    كاتب ومحرر اخبار اعمل في موقع دراسات تقنية .

    إرسال تعليق