Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Author:
- % Date: 12/6/2017
- ec(A,B,C) :-D is B*B - 4 *A * C,D < 0, write("Nu are solutii").
- ec(A,B,C) :-D is B*B - 4 * A * C,D = 0, X1 is (-B)/(2*A), write(X1).
- ec(A,B,C) :- D is B*B - 4*A*C,D > 0, X1 is ((-B) + sqrt(D))/(2*A),
- X2 is ((-B)-sqrt(D))/(2*A), write("X1="),write(X1),
- write("X2="),write(X2).
- suma(1,1).
- suma(N,F) :- N>0, N1 is N-1, suma(N1,F1),F is 1/N + F1.
- ackerman(0,N,R):-R is N+1, N > 0.
- ackerman(M,0,R):-M1 is M-1,ac(M1,1,R),M > 0.
- ackerman(M,N,R):- M1 is M - 1, N1 is N-1, ac(M,N1,R1), ac(M1,R1,R), M > 0, N > 0.
- factorial(0,1).
- factorial(N,F) :- N>0, N1 is N-1, factorial(N1,F1), F is N * F1.
- ff(M,N,R) :- N < M, factorial(N,F), R is M * F .
- ff(M,N,R) :- N >= M, R is N- M.
- pow(_,0,R):-R is 1.
- pow(N,M,R):-M>0,M1 is M-1,pow(N,M1,R1),R is R1*N.
- f(M,N,R) :- N < M, pow(N,M,R).
- f(M,N,R) :- N >=M, R is M* N.
- %CATE NUMARE POZITIVE SE GASESC INTR-O LISTA
- poz([],0).
- poz([P|Rest], Poz) :- P >= 0, poz(Rest,P1), Poz is P1 + 1.
- poz([P|Rest], Poz) :- P < 0, poz(Rest,Poz).
- nr([_P|Rest],Poz) :- nr(Rest,P1), Poz is P1+1.
- nr([],0).
- compar(L1,L2) :- nr(L1,Rez1), nr(L2,Rez2), Rez1>Rez2, write("Prima lista este mai mare").
- compar(L1,L2) :- nr(L1,Rez1), nr(L2,Rez2), Rez1<Rez2, write("A doua lista este mai mare").
- compar(L1,L2) :- nr(L1,Rez1), nr(L2,Rez2), Rez1=Rez2, write("Cele 2 liste sunt egale").
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement