Euclids' Algorithm
Euclids' Algorithm
Updates the GCD of the algorithm GCD(b%a, a) with its recursive calling. (GCD
extended)
Scales well for large integers thats why often preferred in cryptography and other
scientific or other calculations. It dosen't works with non integer values.
APPLICATION:
-> Used in cryptography for GCD and modular inverses.
-> Number theory : Used for solving problems with divisibility and diophantine
equations.
-> Simplifying fractions : Used to simplify the numerator and denominator of a
fraction.
CODE:
import java.util.*;
class EuclidAlg{
static int GCD(int a, int b){
if(a == 0){
return b;
}
return(GCD(b%a, a));
}
int x = input.nextInt();
int y = input.nextInt();