250x250
Link
๋์ GitHub Contribution ๊ทธ๋ํ
Loading data ...
Notice
Recent Posts
Recent Comments
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 |
Tags
- Python
- ์๋ํด๋ผ์ฐ๋
- ADsP
- ์ค๋ฒ์ํ๋ง
- ๋์ํ๋ณธ
- ๋ ๋ฆฝํ๋ณธ
- pandas
- Lambda
- iloc
- ๋ฐ์ดํฐ๋ถ์์ ๋ฌธ๊ฐ
- ์ธ๋์ํ๋ง
- DBSCAN
- ADP
- ์ฃผ์ฑ๋ถ๋ถ์
- ๋ฐ์ดํฐ๋ถ์์ค์ ๋ฌธ๊ฐ
- ๊ตฐ์งํ
- PCA
- ๋น ๋ฐ์ดํฐ๋ถ์๊ธฐ์ฌ
- dataframe
- ํฌ๋กค๋ง
- datascience
- ํ์ด์ฌ
- ๋ฐ์ดํฐ๋ถ๊ท ํ
- ๋น ๋ฐ์ดํฐ
- numpy
- t-test
- ๋ฐ์ดํฐ๋ถ์
- opencv
- LDA
- ํ ์คํธ๋ถ์
Archives
Data Science LAB
[Python] ์ต๋๊ณต์ฝ์ & ์ต์๊ณต๋ฐฐ์ ๊ตฌํ๊ธฐ ๋ณธ๋ฌธ
๐ Python/๊ธฐ์ด
[Python] ์ต๋๊ณต์ฝ์ & ์ต์๊ณต๋ฐฐ์ ๊ตฌํ๊ธฐ
ใ ใ ใ ใ 2022. 12. 16. 19:11728x90
1. ์ต๋ ๊ณต์ฝ์
- ๊ธฐ๋ณธ ์๊ณ ๋ฆฌ์ฆ
# ๋ ์์ ์ต๋ ๊ณต์ฝ์ ๊ตฌํ๊ธฐ
def gcd(a,b):
while b > 0:
a,b = b, a%b
return a
- ๋ชจ๋ ์ด์ฉ
from math import gcd
g = gcd(a, b)
- ์์ฉ (array๋ด ์ซ์์ ์ต๋ ๊ณต์ฝ์ ๊ตฌํ๊ธฐ)
def gcd_n(arr):
gcd = arr[0]
for i in arr:
gcd = math.gcd(gcd, i)
return gcd
2. ์ต์ ๊ณต๋ฐฐ์
- ๊ธฐ๋ณธ ์๊ณ ๋ฆฌ์ฆ
def lcm(a, b):
return a*b // gcd(a,b)
- ๋ชจ๋ ์ด์ฉ
from math import lcm
l = lcm(a,b)
- ์์ฉ (array๋ด ์ซ์์ ์ต์ ๊ณต๋ฐฐ์)
def lcm(arr):
lcm = 1
for i in arr:
lcm = math.lcm(lcm, i)
return lcm
728x90
'๐ Python > ๊ธฐ์ด' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Python] ํน์ ๋ฒ์ ์ผ๋ก ๊ฐ์ํ๊ฒฝ ์ค์นํ๊ธฐ(virtualvenv, venv) (0) | 2023.04.29 |
---|---|
[Python] ์ ๊ท ํํ์์ ์์ฃผ ์ฌ์ฉ๋๋ ๋ฌธ์ ๋ชจ์ (0) | 2022.11.07 |
[Python] ์ ์ฌ ๋์ ๋๋ฆฌ defaultdict() (0) | 2022.11.04 |
[Python] strip(), rstrip(), lstrip() ์ฌ์ฉ ๋ฐฉ๋ฒ ๋ฐ ์์ (0) | 2022.10.31 |
[Python] ์์ ์ฐพ๊ธฐ ์๊ณ ๋ฆฌ์ฆ ๊ตฌํ(Prime Number) (0) | 2022.10.30 |
Comments