File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed
Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ Minimal and clean example implementations of data structures and algorithms in P
9393 - [ valid_sudoku] ( map/valid_sudoku.py )
9494- [ math] ( math )
9595 - [ extended_gcd] ( math/extended_gcd.py )
96- - [ gcd] ( math/gcd.py )
96+ - [ gcd/lcm ] ( math/gcd.py )
9797 - [ prime_test] ( math/prime_test.py )
9898 - [ primes_sieve_of_eratosthenes] ( math/primes_sieve_of_eratosthenes.py )
9999 - [ generate_strobogrammtic] ( math/generate_strobogrammtic.py )
Original file line number Diff line number Diff line change 1- '''
2- Computes gcd of integers a and b using Euclid's Algorithm
3- '''
4-
5-
61def gcd (a , b ):
2+ """Computes the greatest common divisor of integers a and b using
3+ Euclid's Algorithm.
4+ """
75 while True :
86 if b == 0 :
97 return a
108 a , b = b , a % b
9+
10+
11+ def lcm (a , b ):
12+ """Computes the lowest common multiple of integers a and b."""
13+ return a * b / gcd (a , b )
You can’t perform that action at this time.
0 commit comments