Skip to content

Factorial.cs #380

@deljohnson1

Description

@deljohnson1

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions