Advertisement
lossyy

lab6

May 31st, 2021
1,989
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.38 KB | None | 0 0
  1. implement main
  2.     open core, console
  3.  
  4. class predicates
  5.     fact : (real, real [out]).
  6. clauses
  7.     fact(N, 0) :-
  8.         N < 1,
  9.         !.
  10.     fact(N, R) :-
  11.         N1 = N - 1,
  12.         fact(N1, R1),
  13.         R = R1 + 1 / N.
  14.     run() :-
  15.         console::init(),
  16.         fact(read(), R),
  17.         write(R),
  18.         nl.
  19.  
  20. end implement main
  21.  
  22. goal
  23.     mainExe::run(main::run).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement