gcd(a,b) {
if(b==0){
return a;
}
else{
return gcd(b,a % b);
}
The Time Calculation:
We are given integers m and n with m > n >0 . Then m = kn+r with n > r ≥0. In particular m ≥ n+r > 2r .
Performing the same calculation with n and r we have n = k'r+r' with r > r' ≥0. In particular n ≥ r+r' > 2r'
So
(m+n) > 2(r+r')
Renaming m , n , r and r' as m0 , n0 , m1 , n1
(m0+n0) ≥ 21(m1+n1)
Repeating :
(m0+n0) ≥ 2k(mk+nk)
Finally if,
2k ≥ (m0+n0)
then
1 ≥ (mk+nk)
So, since each step takes 2 divisions, we know we can find the gcd with 2k divisions.
p=7 and q=13 so pq=91
p-1=6=2131 and q-1=12=2231
Choose e=5
We are looking for d such that de=1
mod((p-1)(q-1))=1 mod(72).
35*29 = 3145
= 1522586358169246802159262479225089070726226750574991661790882326344643
=3 mod(91)