We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d145c84 commit 4b82c61Copy full SHA for 4b82c61
lcm.py
@@ -1,4 +1,34 @@
1
def lcm(x, y):
2
+ """
3
+ Find least common multiple of 2 positive integers.
4
+ :param x: int - first integer
5
+ :param y: int - second integer
6
+ :return: int - least common multiple
7
+
8
+ >>> lcm(8, 4)
9
+ 8
10
+ >>> lcm(5, 3)
11
+ 15
12
+ >>> lcm(15, 9)
13
+ 45
14
+ >>> lcm(124, 23)
15
+ 2852
16
+ >>> lcm(3, 6)
17
+ 6
18
+ >>> lcm(13, 34)
19
+ 442
20
+ >>> lcm(235, 745)
21
+ 35015
22
+ >>> lcm(65, 86)
23
+ 5590
24
+ >>> lcm(0, 1)
25
+ -1
26
+ >>> lcm(-12, 35)
27
28
29
+ if x <= 0 or y <= 0:
30
+ return -1
31
32
if x > y:
33
greater_number = x
34
else:
0 commit comments