Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. % a)
  2.  
  3. decr(X,NX) :-
  4. NX is X-1.
  5.  
  6. tabela(X, L1) :-
  7. helper(X, [z], L1).
  8. helper(0, L1, L1).
  9. helper(X, L, L2) :-
  10. decr(X, C),
  11. append([s], [L], L1),
  12. helper(C, L1, L2).
  13.  
  14. % b)
  15.  
  16. incr(X,NX) :-
  17. NX is X+1.
  18.  
  19. vsota(0, Y, Z) :- Z is Y.
  20. vsota(X,Y,Z) :-
  21. decr(X, C1),
  22. incr(Y, C2),
  23. vsota(C1, C2, Z).
  24.  
  25. % c)
  26.  
  27. zmnozek(X,Y,Z) :-
  28. Z is X*Y.
  29.  
  30. % d)
  31.  
  32. stevilo(0, _).
  33. stevilo(N,X) :-
  34. C is N-1,
  35. append([1], X, L1),
  36. stevilo(C, L1).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement