Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* fatorial recursivo */
- fatorial(1,1) :- !.
- fatorial(N,F):- X is N-1,
- fatorial(X, Y),
- F is N*Y,
- !.
- /* exercício 1 - fibonacci */
- fib(1,0) :- !.
- fib(2,1) :- !.
- fib(N,F) :- X is N-1,
- Y is N-2,
- fib(X,A),
- fib(Y,B),
- F is A+B,
- !.
- /* exercício 2 - número natural */
- nat(X) :- positivo(X),
- A is round(X),
- A =:= X.
- positivo(X) :- X > 0.
Advertisement
Add Comment
Please, Sign In to add comment