Write a Java Program to find GCD (HCF) of Two Numbers

By | January 20, 2017

Write a Java Program to find GCD (HCF) of Two Numbers


The greatest common divisor (gcd) of two or more integers, when at least one of them is not zero, is the largest positive integer that is a divisor of both numbers.

For example, the GCD of 8 and 12 is 4.

This is java program to find the gcd of given two numbers. GCD is calculated using Euclidean Algorithm.

  • Here is the source code of the Java Program to Find the GCD of 2 Numbers. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.

SOURCE CODE ::

 

 

OUTPUT ::

 

 

Leave a Reply