Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with factorial function #166

Closed
DomHeadroom opened this issue Feb 17, 2023 · 5 comments
Closed

Problem with factorial function #166

DomHeadroom opened this issue Feb 17, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@DomHeadroom
Copy link
Contributor

DomHeadroom commented Feb 17, 2023

Describe the bug
If I try to do the factorial of a negative number instead of giving me Nan as result it give the factorial of the number as it was a positive number but negative, for example if try to do -5! it give me -120.

And I also wanted to report that instead of giving Nan as it's currently written in the code 0! should give as a result 1.
https://www.thoughtco.com/why-does-zero-factorial-equal-one-3126598

To Reproduce
Steps to reproduce the behavior:

  1. Press the minus button
  2. Press a random number
  3. Then click the factorial button

Expected behavior
-5! should give me as a result Nan

Screenshots/videos
https://media.discordapp.net/attachments/831525884069675067/1076231040437342319/IMG_20230217_205730.jpg

Smartphone (please complete the following information):

  • Device: Poco x3 nfc
  • OS: Android 12, miui 13.0.4
  • Version: 2.0.0 from f-droid
  • Language: Italian
@DomHeadroom DomHeadroom added the bug Something isn't working label Feb 17, 2023
@Darkempire78
Copy link
Owner

-5! is like -(5!), but you are right, (-5)! gives -120 instead of NaN

@DomHeadroom
Copy link
Contributor Author

But it does this in any case even if the -5 is a result of a previous operation

@lefterisgar
Copy link
Collaborator

Also if you type (5)! it will give you 5. Probably related. For some reason, when there are parentheses before the ! symbol, the code doesn't reach the factorial function.

@Darkempire78 Darkempire78 added this to the Important milestone Feb 17, 2023
@Darkempire78
Copy link
Owner

I fixed factoriel of 0

@lefterisgar lefterisgar modified the milestones: 2.x.x, 2.2.0 Feb 26, 2023
@Darkempire78
Copy link
Owner

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants