About 1,290 results
Open links in new tab
  1. Euclidean algorithm

    Mathematical algorithm
    • Work Report
    • Email
    • Rewrite
    • Speech
    • Title Generator
    • Smart Reply
    • Poem
    • Essay
    • Joke
    • Instagram Post
    • X Post
    • Facebook Post
    • Story
    • Cover Letter
    • Resume
    • Job Description
    • Recommendation Letter
    • Resignation Letter
    • Invitation Letter
    • Greeting Message
    • Try more templates
  1. Euclid's algorithm is a method to compute the Greatest Common Divisor (GCD) of two integers. It works by repeatedly replacing the larger number with its remainder when divided by the smaller number until one of the numbers becomes zero. The other number at this point is the GCD.

    Recursive Implementation

    public class EuclidAlgorithm {
    // Method to find GCD using recursion
    public static int gcd(int a, int b) {
    if (b == 0) {
    return a; // Base case: when b becomes 0, a is the GCD
    }
    return gcd(b, a % b); // Recursive call with b and remainder
    }

    public static void main(String[] args) {
    int num1 = 48, num2 = 18;
    System.out.println("GCD of " + num1 + " and " + num2 + " is: " + gcd(num1, num2));
    }
    }
    Copied!

    Output:

    GCD of 48 and 18 is: 6
    Copied!

    Iterative Implementation

    Feedback
  2. Java - Euclid algorithm, find the GCD of two integers

    Feb 2, 2026 · Java programming exercises and solution: Write a Java program to prove that Euclid’s algorithm computes the greatest common divisor of two …

  3. Euclid’s algorithm for the greatest common divisor in Java ... - vogella

    Feb 26, 2026 · Euclid’s algorithm remains popular due to its simplicity, efficiency, and suitability for most greatest common divisor-related tasks.

  4. Euclidean Algorithm for Greatest Common Divisor (GCD) …

    Overview This article explains Euclid's Algorithm for Greatest Common Divisor (GCD) of 2 numbers. It then shows how to implement Euclidean Algorithm in …

  5. Euclid.java - Princeton University

    Aug 11, 2022 · /****************************************************************************** * Compilation: javac Euclid.java * Execution: java Euclid p q * * Reads two command-line arguments p …

  6. EuclideanAlgos/ExtendedEuclideanAlgorithm.java at main - GitHub

    Euclidean and Extended Euclidean algorithms along with a proper modulus method - EuclideanAlgos/ExtendedEuclideanAlgorithm.java at main · matthall7/EuclideanAlgos

  7. GCD of two numbers Euclidean algorithm in java (iterative/ recursive)

    The Euclidean algorithm is based on the principle that the greatest common divisor of two numbers does not change if the larger number is replaced by its difference with the smaller number. We will …

  8. How to write Extended Euclidean Algorithm code wise in Java?

    The extended Euclidean algorithm will be done the same way, saving two s values prevPrevS and prevS, and two t values prevPrevT and prevT. I'll let you work out the details.

  9. Java Program to Find G.C.D and L.C.M of Two Numbers Using Euclid\'s …

    Euclid’s Algorithm is an efficient algorithm which helps us to find G.C.D and L.C.M of two numbers. In this article, we are learning to write a Java program to find the G.C.D and L.C.M of two numbers using …

  10. Euclidean Algorithm: GCD Explained with C++, Java …

    Oct 27, 2025 · Master the Euclidean Algorithm with our step-by-step guide to find the GCD (Greatest Common Divisor). See code examples in C++/Java, and real …