Skip to content

Conversation

@Astralcircle
Copy link
Contributor

@Astralcircle Astralcircle commented Jan 29, 2025

Adds a simple E2 function to calculate the factorial of a number.

@Alexandre425
Copy link
Contributor

Wouldn't it be more efficient to check whether n is greater than 171, returning +inf immediately?

@Astralcircle
Copy link
Contributor Author

math.min protects against NaN

@CornerPin
Copy link
Contributor

CornerPin commented Jan 29, 2025

I think it would be better to precompute the results instead and store them in a lookup table for $O(1)$ time, otherwise the cost should be made proportional to n. Should probably return NaN for $n \lt 0$ as well.

Co-authored-by: thegrb93 <[email protected]>
@thegrb93 thegrb93 merged commit c75ee43 into wiremod:master Jan 30, 2025
1 check passed
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

Successfully merging this pull request may close these issues.

4 participants