-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnumberTheory.cpp
61 lines (43 loc) · 932 Bytes
/
numberTheory.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <vector>
#include <iostream>
#include "numberTheory.hpp"
#include <cmath>
#include <string>
//#include "ReallyLongInt.cpp"
using namespace std;
ReallyLongInt numberTheory::extendedEuclid(const ReallyLongInt& a, const ReallyLongInt& b,ReallyLongInt& x, ReallyLongInt& y)
{
if(b.equal(0))
{
x=1;
y=0;
return a;
}
else
{
ReallyLongInt d;
numberTheory t;
d=t.extendedEuclid(b,a%b,x,y);
ReallyLongInt x1;
x1=y;
ReallyLongInt y1;
y1=x-y*(a/b);
x=x1;
y=y1;
return d;
}
}
/*
int main(){
ReallyLongInt a(12);
ReallyLongInt b(8);
ReallyLongInt gcd;
ReallyLongInt x;
ReallyLongInt y;
numberTheory t;
gcd=t.extendedEuclid(a,b,x,y);
cout<<"GCD is: "<<gcd.toString()<<endl;
cout<<"x value: "<<x.toString()<<endl;
cout<<"y value: "<<y.toString()<<endl;
}
**/