Skip to content

Commit 3081ea0

Browse files
committed
First commit
1 parent 87a1d13 commit 3081ea0

File tree

3 files changed

+53
-5
lines changed

3 files changed

+53
-5
lines changed

.idea/misc.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 30 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Euclid Algorithm
2+
3+
def gcd(m, n):
4+
if m < n:
5+
m, n = n, m
6+
if m % n == 0:
7+
return n
8+
else:
9+
diff = m - n
10+
return gcd(max(n, diff), min(n, diff))
11+
12+
13+
print(gcd(11, 2222))
14+
# The function prints 11 because 11 is the greatest common divisor (GCD) of the numbers 11 and 2222.
15+
# Let's break down the process:
16+
# Initial Call: gcd(11, 2222)
17+
# Swap Values: Since 11 < 2222, swap them. Now it's gcd(2222, 11)
18+
# Check Remainder: 2222 % 11 is not 0, so it calculates the difference: 2222 - 11 = 2211
19+
# Recursive Call: gcd(2211, 11)
20+
# Check Remainder: 2211 % 11 is 0

0 commit comments

Comments
 (0)