Sheyshya

hcf and factorial

Dec 5th, 2021
909
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. PREDICATES
  2. hcf(integer, integer, integer)
  3. CLAUSES
  4. hcf(X, Y, X):-
  5. Y mod X = 0.
  6. hcf(X,Y,Z):-
  7. S = Y mod X,S<>0, hcf(S, X, Z).
  8. GOAL
  9. hcf(5,10,X).
  10.  
  11.  
  12.  
  13.  
  14. //FACPTIEAL
  15. PREDICATES
  16. factorial(unsigned,real)
  17. Clauses
  18. factorial(1,1):-!.
  19. factorial(N,FactN):-
  20. M=N-1,
  21. factorial(M,FactM),
  22. FactN=N*FactM.
  23. Goal
  24. factorial(5,F).
RAW Paste Data