Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in Least Common Multiple algorithm #943

Open
gkwaerp opened this issue Aug 24, 2020 · 0 comments
Open

Error in Least Common Multiple algorithm #943

gkwaerp opened this issue Aug 24, 2020 · 0 comments

Comments

@gkwaerp
Copy link

gkwaerp commented Aug 24, 2020

Brief Intro

https://github.com/raywenderlich/swift-algorithm-club/tree/master/GCD
The code fails (fatalError) in various valid scenarios, e.g. lcm(3, 4) --> should be 12.

More Details

guard (m & n) != 0 else { throw LCMError.divisionByZero }

This is not a division by zero check, nor is it a relevant check for this algorithm.
Would recommend changing to e.g.

guard m > 0, n > 0 else { throw LCMError.nonPositiveNumbers } //Must be added to LCMError.
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

No branches or pull requests

1 participant