From 15c42c1c1290997601eddd3a5fce34924760b7de Mon Sep 17 00:00:00 2001 From: Rui Ge Date: Mon, 31 Oct 2022 01:50:50 -0700 Subject: Added Rui Ge's submission. Added an MetaOCaml impl, a Prolog impl, and added myself to people.json. --- entries/gerui/fib.pl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 entries/gerui/fib.pl (limited to 'entries/gerui/fib.pl') diff --git a/entries/gerui/fib.pl b/entries/gerui/fib.pl new file mode 100644 index 0000000..0065246 --- /dev/null +++ b/entries/gerui/fib.pl @@ -0,0 +1,15 @@ +% To my surprise, there has been no Prolog implementation submitted so far. +% To get the ball rolling, and to pay respect to Prolog, here is a well-known Prolog implementation of the Fibonacci sequence. + +% fib(N, S): S is the Nth Fibonacci number. + +:- table fib/2. + +fib(0, 1) :- !. +fib(1, 1) :- !. +fib(N, S) :- N > 1, + N1 is N-1, + N2 is N-2, + fib(N1, S1), + fib(N2, S2), + S is S1+S2. -- cgit v1.2.3-70-g09d2