A
A
alan4042019-11-24 11:19:31
Haskell
alan404, 2019-11-24 11:19:31

Extension of Fibonacci numbers to negative numbers, what does it mean?

Task: Define two Haskell functions (recursive and using list comprehensions) by variants.
Tell me what it means to expand Fibonacci numbers to negative numbers?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shurshur, 2019-11-24
@alan404

f(0)=1
f(1)=1
f(2)=f(0)+f(1)
...
f(n)=f(n-2)+f(n-1)
To be extended to negative numbers? Instead of f(n)=f(n-2)+f(n-1) we use f(n)=f(n+2)-f(n+1) and go "from top to bottom":
f(-1) =f(1)-f(0)=0
f(-2)=f(0)-f(-1)=1
f(-3)=f(-1)-f(-2)=-1
f(-4)=f(-2)-f(-3)=2
...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question