ks2colorworld / Data-Structures-With-Python

자료구조 강의에서 다뤄진 내용의 셀프 실습 - https://www.youtube.com/playlist?list=PLsMufJgu5933ZkBCHS7bQTx0bncjwi4PK
1 stars 0 forks source link

최대공약수(GCD) 계산 알고리즘 #1

Closed ks2colorworld closed 10 months ago

ks2colorworld commented 10 months ago
image

https://www.youtube.com/watch?v=M2mcJvmYpWY&list=PLsMufJgu5933ZkBCHS7bQTx0bncjwi4PK&index=3&ab_channel=Chan-SuShin&t=987

ks2colorworld commented 10 months ago

반복문 알고리즘 개선을 위한 코드 비교 (강의 내용에서 언급)

  while a!=0 and b != 0:
-    if a>b: a=a-b
-    else: b=b-a
+    if a>b: a=a%b
+    else: b=b%a
    whileIndex += 1
ks2colorworld commented 10 months ago