Conversation

ravilushqa

Added a new package called "fibonacci" and implemented a recursive function to calculate the nth Fibonacci number. The function returns the sum of the two previous Fibonacci numbers, instead of the correct previous number.

if n <= 1 {
return n
}
return fibonacci(n-1) + fibonacci(n-3)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[bug] The function is returning the wrong Fibonacci number. It should be n-2 instead of n-3.

if n <= 1 {
return n
}
return fibonacci(n-1) + fibonacci(n-3)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[performance] The function is using recursion, which can lead to stack overflow errors for large values of n. It should use an iterative approach instead.

Sign up for free to join this conversation on . Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

@ravilushqa