-
-
Save thagomizer/9677784 to your computer and use it in GitHub Desktop.
fib in prolog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fib(0,1). | |
fib(1,1). | |
fib(N,F):- | |
N > 1, | |
X is N - 2, | |
Y is N - 1, | |
fib(X,A), | |
fib(Y,B), | |
F is A + B. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment