diff --git a/js1.html b/js1.html index 80ce618..92584fe 100644 --- a/js1.html +++ b/js1.html @@ -277,6 +277,17 @@
Note: use your brain to understand it.
+ +Better time complexity than Method 1 and equivalent to Method 2
+
+const GCD = (a,b) => {
+ while(a != b){
+ [a,b] = a > b ? [a-b, b] : [a, b-a];
+ }
+ return a || b
+}
+