From 2bf5effe95641667a1ed51c04eff7760f6a42ef4 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Mon, 3 Oct 2016 13:00:14 +0200 Subject: Initial --- numalgo.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 numalgo.cpp (limited to 'numalgo.cpp') diff --git a/numalgo.cpp b/numalgo.cpp new file mode 100644 index 0000000..1db0763 --- /dev/null +++ b/numalgo.cpp @@ -0,0 +1,50 @@ +#include +#include "numalgo.h" + +using namespace std; + +Bigint gcd(Bigint a,Bigint b){ + while(true){ + if(a==0)return b; + if(b==0)return a; + if(a>=b)a=a.divmod(b).second; + else b=b.divmod(a).second; + } +} + +Bigint egcd(const Bigint &a,const Bigint &b,Bigint &x,Bigint &y){ + Bigint x2(0),y2(1),r(a),r2(b); + x=1; y=0; + //cerr<