summaryrefslogtreecommitdiff
path: root/content/math/extendedEuclid.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'content/math/extendedEuclid.cpp')
-rw-r--r--content/math/extendedEuclid.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/content/math/extendedEuclid.cpp b/content/math/extendedEuclid.cpp
new file mode 100644
index 0000000..ecf4a16
--- /dev/null
+++ b/content/math/extendedEuclid.cpp
@@ -0,0 +1,6 @@
+// a*x + b*y = ggt(a, b)
+array<ll, 3> extendedEuclid(ll a, ll b) {
+ if (a == 0) return {b, 0, 1};
+ auto [d, x, y] = extendedEuclid(b % a, a);
+ return {d, y - (b / a) * x, x};
+}