FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pygorithm/pygorithm/math/lcm.py at master · OmkarPathak/pygorithm · GitHub
OmkarPathak
/
pygorithm
Public
Notifications
You must be signed in to change notification settings
Fork
504
Star
4.4k
Code
Issues
3
Pull requests
6
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
pygorithm
/
pygorithm
/
math
/
lcm.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
42 lines (34 loc) · 806 Bytes
Breadcrumbs
pygorithm
/
pygorithm
/
math
/
lcm.py
Copy path
File metadata and controls
42 lines (34 loc) · 806 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
Author: OMKAR PATHAK
Created at: 16th August 2017
"""
from
functools
import
reduce
import
inspect
def
lcm
(
_list
):
"""LCM
function to find LCM for given list of elements
:param _list: _list of which LCM is to be found out
"""
def
__lcm
(
a
,
b
):
"""
helper function for finding LCM
:param a:
:param b:
:return: lcm
"""
if
a
>
b
:
greater
=
a
else
:
greater
=
b
while
True
:
if
greater
%
a
==
0
and
greater
%
b
==
0
:
lcm_
=
greater
break
greater
+=
1
return
lcm_
return
reduce
(
lambda
x
,
y
:
__lcm
(
x
,
y
),
_list
)
def
get_code
():
"""
returns the code for the lcm function
"""
return
inspect
.
getsource
(
lcm
)
Back
|
FazBrowse Home
|
New Git URL