TheAlgorithms / C-Sharp

All algorithms implemented in C#.
GNU General Public License v3.0
7.13k stars 1.52k forks source link

Factorial.cs #380

Closed deljohnson1 closed 1 year ago

deljohnson1 commented 1 year ago

The Algorithms.Numeric.Factorial.Calculate function takes an int as input and returns a long; the function will overflow with an input greater than 20. Calculate should take a BigInteger as input and return one as output.

Additionally, the function checks input for less than zero. I would recommend putting input error checking outside of the Calculate function, in the ap[plications code (not the library), so that iterative functions that call it don't take the performance hit. In this case I would merely state it in the comment.

I have made the change in my test environment and it appears the change only breaks the Maclaurin.cs file; the fix for this appears to be to perform explicit type conversion on the return result.

I can submit the corrections if desired.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

MandeepCodes commented 1 year ago

Is this issue closed ? I can take it up if not complete.

deljohnson1 commented 1 year ago

You can have it.

From: Mandeep Singh @.> Sent: Wednesday, April 12, 2023 1:20 PM To: TheAlgorithms/C-Sharp @.> Cc: deljohnson1 @.>; Assign @.> Subject: Re: [TheAlgorithms/C-Sharp] Factorial.cs (Issue #380)

Is this issue closed ? I can take it up if not complete.

— Reply to this email directly, view it on GitHub https://github.com/TheAlgorithms/C-Sharp/issues/380#issuecomment-1505728580 , or unsubscribe https://github.com/notifications/unsubscribe-auth/A5NU4AB7M2R7HI2ITL5XK33XA3W4NANCNFSM6AAAAAAUZD5JNA . You are receiving this because you were assigned.Message ID: @.***>

siriak commented 1 year ago

It's being worked on in https://github.com/TheAlgorithms/C-Sharp/pull/390

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 7 days with no activity.