Changeset 283bb9f in mainline for common/include/adt/gcdlcm.h
- Timestamp:
- 2025-09-18T13:50:14Z (2 weeks ago)
- Branches:
- master
- Children:
- 32ae27bb
- Parents:
- f9c4c433
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
common/include/adt/gcdlcm.h
rf9c4c433 r283bb9f 42 42 static inline type name(type a, type b) \ 43 43 { \ 44 if (a == 0) \45 return b; \46 \47 44 while (b != 0) { \ 48 if (a > b) \ 49 a -= b; \ 50 else \ 51 b -= a; \ 45 type remainder = a % b; \ 46 a = b; \ 47 b = remainder; \ 52 48 } \ 53 49 \ … … 58 54 static inline type name(type a, type b) \ 59 55 { \ 60 return (a * b) / gcd(a, b); \56 return (a / gcd(a, b)) * b; \ 61 57 } 62 58
Note:
See TracChangeset
for help on using the changeset viewer.