Open
Description
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.
Metadata
Metadata
Assignees
Labels
No labels