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

Factorial of a negative number does not exist #1008

Open
njiddasalifu opened this issue Mar 17, 2023 · 18 comments
Open

Factorial of a negative number does not exist #1008

njiddasalifu opened this issue Mar 17, 2023 · 18 comments

Comments

@njiddasalifu
Copy link

This issue is addressing the fact that in the factorialrecursive implementation, it says if number is not greater than 1 then return 1. its not true for all cases cox fact of a neative is undefined.

@njiddasalifu
Copy link
Author

I have solved this already check PR for merged

@HemanthPaila
Copy link

Hi there,

I want to contribute to this project and take on this issue as my first task. Could you please assign it to me? I am excited to work towards resolving it and will keep the team updated on my progress.

Thanks!

@xyn22
Copy link

xyn22 commented Apr 8, 2023

I have solved this already check PR for merged

Please link your PR to this issue.

@njiddasalifu
Copy link
Author

@xyn22 you can find the PR link here #1021

@cynthiamarshal
Copy link

This issue pertains to the factorial recursive implementation. Currently, the implementation states that if the number is not greater than 1, it should return 1. However, this is not entirely accurate because the factorial of a negative number is undefined. DGme

@utkarsh-shrivastav77
Copy link

Hi is this issue still open

@njiddasalifu
Copy link
Author

njiddasalifu commented May 15, 2023 via email

@jesicaakon
Copy link

That is correct. The factorial of a negative number does not exist. The factorial function is defined as the product of all positive integers less than or equal to a given number. Since negative numbers are not positive, they cannot be part of the product. Therefore, the factorial of a negative number is undefined.

Here are some examples of factorials of positive integers:

1! = 1
2! = 2
3! = 6
4! = 24
5! = 120
Here are some examples of factorials of negative integers:

(-1)! = undefined
(-2)! = undefined
(-3)! = undefined
(-4)! = undefined
(-5)! = undefined
You can also check factorial types of issues at Employee Connection

@resicajasi
Copy link

resicajasi commented May 19, 2023

the factorial recursive implementation, the statement that returns 1 when the number is not greater than 1 is not suitable for all cases. This is because the factorial of a negative number is undefined. It's important to handle negative numbers as a special case and either return an error or provide appropriate validation to prevent undefined behavior in the factorial function. I would invite you to visit my blog for more informative updates getmyccpay.com

@lazarljubenovic
Copy link

The GPT spam era is starting ☺️

@Anekantjainsagar
Copy link

Facing an issue after pulling code from GitHub while running npm run lint

@ZepLeonard
Copy link

ZepLeonard commented Jun 1, 2023 via email

@raidenkhan
Copy link

the factorial recursive implementation, the statement that returns 1 when the number is not greater than 1 is not suitable for all cases. This is because the factorial of a negative number is undefined. It's important to handle negative numbers as a special case and either return an error or provide appropriate validation to prevent undefined behavior in the factorial function. I would invite you to visit my blog for more informative updates getmyccpay.com

Yes I agree the base case in the recurssive statement should state if number <=1 return 1 which handles pretty much everythin

@ihemanthm
Copy link

I agree with the person stated that the factorial of number <0 i.e, -1!, -2!,... all results undefined whereas the values of -0!,0! and 1! results as 1 and the rest continues

@sumukhj1219
Copy link

Assign it to me

@Sanil-Surve
Copy link

Hii I am interested in solving this issue

@Sanil-Surve
Copy link

I have solved this issue take a look at my PR

@njiddasalifu
Copy link
Author

njiddasalifu commented Jun 20, 2024 via email

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

No branches or pull requests

15 participants