Add new exercise
parent
94bb367486
commit
eba10ebdd0
|
@ -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).
|
Loading…
Reference in New Issue