Skip to content

Instantly share code, notes, and snippets.

@rezzycavalheiro
Forked from hoelzro/gist:3973656
Created September 18, 2018 12:12
Show Gist options
  • Save rezzycavalheiro/dd69f2bb70a4e7409ecdf72986ee12dd to your computer and use it in GitHub Desktop.
Save rezzycavalheiro/dd69f2bb70a4e7409ecdf72986ee12dd to your computer and use it in GitHub Desktop.
Fibonacci sequence implemented in Prolog
fib(0, 1) :- !.
fib(1, 1) :- !.
fib(N, Result) :- N1 is N - 1, N2 is N - 2, fib(N1, Result1), fib(N2, Result2), Result is Result1 + Result2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment