Skip to content
This repository has been archived by the owner on Mar 29, 2023. It is now read-only.

Incorrect result of Fibonacci Number #101

Open
studyeveryday7 opened this issue May 22, 2021 · 5 comments
Open

Incorrect result of Fibonacci Number #101

studyeveryday7 opened this issue May 22, 2021 · 5 comments
Assignees

Comments

@studyeveryday7
Copy link

Describe the bug

In the Fibonacci Number module, when input a negative number like -6, the output is incorrect.

Expected behavior

I expected the result should be not negative. Maybe change the input negative number to positive number can solve it, and add a dialog to show the reason.

To reproduce

  1. Open NCalc+ (Which is build from latest source code)
  2. Go to Fibonacci Number module
  3. Input -6
  4. Click the evaluate bottom
  5. Incorrect result has been displayed

Configuration

  • Android version 9
  • device MI 8 Lite

Screenshots

image

@danger-ahead
Copy link

Hi can you please assign me? I can fix it

@studyeveryday7
Copy link
Author

Hi can you please assign me? I can fix it

sure!thank you

@danger-ahead
Copy link

@axkr I have created a pull request with the fix.
Thanks!

@axkr
Copy link
Collaborator

axkr commented May 23, 2021

Sorry for not looking earlier, but I think the negative result is OK:

@hakanai
Copy link

hakanai commented Mar 13, 2022

-8 is indeed the correct answer, assuming the standard positioning of the sequence with Fib(0) = 0:

  • Fib(-6) = -8
  • Fib(-5) = 5
  • Fib(-4) = -3
  • Fib(-3) = 2
  • Fib(-2) = -1
  • Fib(-1) = 1
  • Fib(0) = 0
  • Fib(1) = 1
  • Fib(2) = 1
  • Fib(3) = 2
  • Fib(4) = 3

The reporter possibly was off by one or something as every second value is indeed not negative.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants