Skip to content

Fix LCM overflow handling and README GCD/LCM descriptions#3

Merged
amartinsmg merged 1 commit intomainfrom
codex/check-repository-for-implementation-errors
Feb 25, 2026
Merged

Fix LCM overflow handling and README GCD/LCM descriptions#3
amartinsmg merged 1 commit intomainfrom
codex/check-repository-for-implementation-errors

Conversation

@amartinsmg
Copy link
Owner

Motivation

  • Prevent incorrect behavior when computing lcm due to intermediate int overflow and ensure correct absolute-value handling for long long results.
  • Correct the documentation where the gcd.h and lcm.h feature descriptions were accidentally swapped in the README.md.

Description

  • Updated src/lcm.h to cast operands to long long before multiplication and compute the absolute value with llabs to avoid intermediate overflow and match the return type.
  • Replaced #include <math.h> with #include <stdlib.h> in src/lcm.h so llabs is available.
  • Fixed the swapped feature descriptions for gcd.h and lcm.h in README.md so each header maps to the correct description.

Testing

  • Ran make test which built the test executable successfully.
  • Executed ./debug/test and all tests passed successfully.

Codex Task

@amartinsmg amartinsmg merged commit b8810bf into main Feb 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant