plz I beg u guys solve this
I will award u more points
Attachments:
meghana0505:
Java Program to Find GCD of Two Numbers. The GCD (Greatest Common Divisor) of two numbers is the largest positive integer number that divides both the numbers without leaving any remainder. For example. GCD of 30 and 45 is 15.
Answers
Answered by
2
import java.util.*;
public class HCFOFNumbers {
public static int hcf(int a, int b) {
if (b == 0)
return a;
else
return hcf(b, a % b);
}
public static int hcf(int a, int b, int c) {
return hcf(hcf(a, b), c);
}
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter Number 1: ");
int num1 = input.nextInt();
System.out.print("Enter Number 2: ");
int num2 = input.nextInt();
System.out.print("Enter Number 3: ");
int num3 = input.nextInt();
int hcfOfNumbers = HCFOFNumbers.hcf(num1, num2, num3);
System.out.println("HCF of three numbers " + num1 + "," + num2
+ " and " + num3 + " is: " + hcfOfNumbers);
}
Answered by
1
Answer:
SEE ATTACHMENT
Explanation:
Similar questions