javascript-algorithms
javascript-algorithms copied to clipboard
Factorial of a negative number does not exist
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.
I have solved this already check PR for merged
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!
I have solved this already check PR for merged
Please link your PR to this issue.
@xyn22 you can find the PR link here https://github.com/trekhleb/javascript-algorithms/pull/1021
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
Hi is this issue still open
No check there is a PR for the issue already. On Mon, 15 May 2023 at 18:11 Utkarsh Shrivastav @.***> wrote:
Hi is this issue still open
— Reply to this email directly, view it on GitHub https://github.com/trekhleb/javascript-algorithms/issues/1008#issuecomment-1548240315, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWTKIXIJT6FZ53LQUI2D4E3XGJPVLANCNFSM6AAAAAAV54MKEU . You are receiving this because you authored the thread.Message ID: @.***>
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
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
The GPT spam era is starting ☺️
Facing an issue after pulling code from GitHub while running npm run lint
您的信件已经收到,我会尽快查阅,谢谢! ——林泽鹏 This is an automatic reply, confirming that your e-mail was received.Thank you
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
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
Assign it to me
Hii I am interested in solving this issue
I have solved this issue take a look at my PR
This has been solved already.
On Thu, 20 Jun 2024 at 15:22 Sanil Surve @.***> wrote:
I have solved this issue take a look at my PR
— Reply to this email directly, view it on GitHub https://github.com/trekhleb/javascript-algorithms/issues/1008#issuecomment-2180840949, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWTKIXIRZLKUENOURMUEPODZILQUBAVCNFSM6AAAAAAV54MKEWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBQHA2DAOJUHE . You are receiving this because you authored the thread.Message ID: @.***>