Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit aa158fa

Browse files
Update 592._Fraction_Addition_and_Subtraction.md
1 parent 44a211b commit aa158fa

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

‎docs/Leetcode_Solutions/592._Fraction_Addition_and_Subtraction.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,11 @@ class Solution(object):
4848
:type expression: str
4949
:rtype: str
5050
"""
51-
def gcd(big, small):
52-
if big < small:
53-
small, big = big, small
54-
remainder = big % small
55-
if remainder == 0:
56-
return small
57-
else:
58-
return gcd(small, remainder)
59-
51+
def gcd(a, b):
52+
if a == 0:
53+
return b
54+
return gcd(b % a, a)
55+
6056
def gcm(num1, num2):
6157
return num1 * num2 // gcd(num1, num2)
6258

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /