% Prolog program for finding factorial using recursion---- % Alamgir Hossain, CSE, JUST fact(0,1). fact(N,F):- ( N>0 -> ( N1 is N-1, fact(N1,F1), F is N*F1 ) ; write('N should be greater than 0.') ).% Output----------
% fact(5,R).
%R = 120
% Prolog program for finding factorial using recursion---- % Alamgir Hossain, CSE, JUST fact(0,1). fact(N,F):- ( N>0 -> ( N1 is N-1, fact(N1,F1), F is N*F1 ) ; write('N should be greater than 0.') ).% Output----------
No comments:
Post a Comment