Hi,

I am currently working on the Rosetta Code: Fibonacci sequence and the test values seems to be not correct. According to the test, fibonacci(3) should return 1, fibonacci(5) should return 3 and fibonacci(10) should return 34. However, the fibonacci sequence is: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55… and F3 should be 2, F5 should be 5 and F10 should be 55.

Please correct me if I am wrong.

Thank you.

@luping8576 I think it is asking for the value at the nth position in the sequence of Fibonacci numbers. Not calculate the Fibonacci number Fn. Haven’t done it myself. just saw your post and thought i’d have a look. Had to read it three times to work out what it was actually asking. it’s a bit subtle!

@mdc I think I also mean nth Fibonacci number.

Fibonacci sequence:

0(nth0), 1(nth1), 1(nth2), 2(nth3), 3(nth4), 5(nth5), 8(nth6), 13(nth7), 21(nth8), 34(nth9), 55(nth10).

Please check out the following two resources:

www.geeksforgeeks.org+program-for-nth-fibonacci-number

en.wikipedia.org+wiki+Fibonacci_number

(Sorry, I cannot post links, please replace plus signs with slashes)

@luping8576 You’re correct. I responded at silly o’clock and didn’t think it through or try to do solution myself. Looking at it again it seems to be wanting the result as if it were a 1-based sequence and not a 0-based sequence. When I tackled it this way I got the tests to pass. Hence fibbonacci(0) would not be valid input but n >= 1 would.

Hope that helps.

@mdc Thanks for your help. I know the solution . I am just wondering if the test itself is correct, because it is different from what I’ve learned.

if you think it needs reporting or w change in description you can report it as a bug

Thank you for helping make FCC better. Bugs can be reported as GitHub Issues. Whenever reporting a bug, please check first that there isn’t already an issue for it and provide as much detail as possible.

The challenge was recently updated to use zero based indexing.