Add new exercise

main
kirbylife 2023-10-28 00:52:05 -06:00
parent 94bb367486
commit eba10ebdd0
1 changed files with 13 additions and 0 deletions

View File

@ -0,0 +1,13 @@
fib(N) :-
write(1),
write(", "),
CounterMinusOne is N - 1,
fib(0, 1, CounterMinusOne).
fib(N1, N2, Counter) :-
Counter > 0,
Result is N1 + N2,
write(Result),
write(", "),
CounterMinusOne is Counter - 1,
fib(N2, Result, CounterMinusOne).