Advertisement
Teammasik

Paradigmas_prolog_lr3

May 18th, 2023
734
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.29 KB | None | 0 0
  1. %task 1 default
  2. summ(0,0).
  3.  
  4. summ(N,X):- N1 is N-1, summ(N1,X1), X is X1 + (4*N-1).
  5.  
  6. %task 1 tail
  7.  
  8. tail(0,T,T).
  9. tail(N,T,R):- N1 is N - 1, T1 is T + (4*N-1),tail(N1,T1,R).
  10.  
  11. %task 2
  12.  
  13. f(0,1).
  14. f(1,2).
  15. f(N,R):-
  16. N1 is N - 1,
  17. N2 is N - 2,
  18. f(N1,R1),
  19. f(N2,R2),
  20. R is R1 - 2 * R2.
  21.  
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement