Skip to content

Commit f6a7a8b

Browse files
committed
Use a and b instead of u and v
1 parent 90840ce commit f6a7a8b

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/algebra/euclid-algorithm.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,18 @@ It's based on a few properties:
112112
Using only these properties, and some fast bitwise functions from GCC, we can implement a fast version:
113113

114114
```cpp
115-
int gcd(int u, int v) {
116-
if (!u || !v)
117-
return u | v;
118-
unsigned shift = __builtin_ctz(u | v);
119-
u >>= __builtin_ctz(u);
115+
int gcd(int a, int b) {
116+
if (!a || !b)
117+
return a | b;
118+
unsigned shift = __builtin_ctz(a | b);
119+
a >>= __builtin_ctz(a);
120120
do {
121-
v >>= __builtin_ctz(v);
122-
if (u > v)
123-
swap(u, v);
124-
v -= u;
125-
} while (v);
126-
return u << shift;
121+
b >>= __builtin_ctz(b);
122+
if (a > b)
123+
swap(a, b);
124+
b -= a;
125+
} while (b);
126+
return a << shift;
127127
}
128128
```
129129

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy