Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

EuclideanAlgorithm in Java

int iterativeGCD(int a, int b) {
    int tmp;
    while (b != 0) {
        if (a < b) {
            tmp = a;
            a = b;
            b = tmp;
        }
        tmp = b;
        b = a % b;
        a = tmp;
    }
    return a;
}
Source by www.baeldung.com #
 
PREVIOUS NEXT
Tagged: #EuclideanAlgorithm #Java
ADD COMMENT
Topic
Name
2+5 =