Least Common Multiple. Using the property that lcm(a, b) * greatest_common_divisor(a, b) = a*b >>> lcm(3, 15) 15 >>> lcm(1, 27) 27 >>> lcm(13, 27) 351 >>> lcm(64, 48) 192
(x: int, y: int)
| 19 | |
| 20 | |
| 21 | def lcm(x: int, y: int) -> int: |
| 22 | """ |
| 23 | Least Common Multiple. |
| 24 | |
| 25 | Using the property that lcm(a, b) * greatest_common_divisor(a, b) = a*b |
| 26 | |
| 27 | >>> lcm(3, 15) |
| 28 | 15 |
| 29 | >>> lcm(1, 27) |
| 30 | 27 |
| 31 | >>> lcm(13, 27) |
| 32 | 351 |
| 33 | >>> lcm(64, 48) |
| 34 | 192 |
| 35 | """ |
| 36 | |
| 37 | return (x * y) // greatest_common_divisor(x, y) |
| 38 | |
| 39 | |
| 40 | def solution(n: int = 20) -> int: |
no test coverage detected