Answer:
Step-by-step explanation:
The following is written in Java. It creates the function that takes in two int values to calculate the gcd. It includes step by step comments and prints the gcd value to the console.
public static void calculateGCD(int x, int y) {
//x and y are the numbers to find the GCF which is needed first
x = 12;
y = 8;
int gcd = 1;
//loop through from 1 to the smallest of both numbers
for(int i = 1; i <= x && i <= y; i++)
{
//returns true if both conditions are satisfied
if(x%i==0 && y%i==0)
//once we have both values as true we store i as the greatest common denominator
gcd = i;
}
//prints the gcd
System.out.printf("GCD of " + x + " and " + y + " is: " + gcd);
}