Skip to content

Implement an overflow-checked version of LCM#77

Open
Astronomy487 wants to merge 2 commits into
rust-num:masterfrom
Astronomy487:iss76-overflow-lcm
Open

Implement an overflow-checked version of LCM#77
Astronomy487 wants to merge 2 commits into
rust-num:masterfrom
Astronomy487:iss76-overflow-lcm

Conversation

@Astronomy487
Copy link
Copy Markdown

Fixes #76 by introducing checked_lcm and checked_gcd_lcm functions. They behave the same as the existing lcm and gcd_lcm functions, except the LCM will be None if and only if the LCM of the two integers is too big for the type they are being stored as. Uses the function checked_mul.

Add `checked_lcm` and `checked_gcd_lcm` as counterparts to existing `lcm` and `gcd_lcm` functions, in which the LCM may be None in the case of overflow.
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.

lcm method overflows for large inputs

1 participant