Respuesta :
Answer:
I've added the complete code as a text attachment
Explanation:
This declares two variables as integer for input
int f1, f2;
Prompts the user for two positive integer inputs
System.out.print("Enter two positive integers: ");
This gets the two integer input from the user
f1 = input.nextInt(); f2 = input.nextInt();
If both inputs are positive, the function is called and the gcf is printed
if (f1 >0&& f2 > 0){
System.out.printf("G.C.F of %d and %d is %d", f1, f2, gcf(f1, f2));}
If otherwise, a message is printed stating that only positive input is required
else{ System.out.print("Positive inputs only"); }
}
The function begins here
[tex]public\ static\ int[/tex] gcf(int a, int b) {
If the second number (b) is 0, the function returns the first number (a)
if ([tex]b == 0[/tex]) { return [tex]a;[/tex] }
If otherwise, the function is called recursively
else { [tex]return[/tex] (gcf([tex]b[/tex], [tex]a \% b[/tex])); }
}
In this exercise we have to use the knowledge of computational language in C to describe the code, like this:
We can find the code in the attached image.
The code can be written more simply as:
int f1, f2;
Prompts the user for two positive integer inputs
System.out.print("Enter two positive integers: ");
f1 = input.nextInt(); f2 = input.nextInt();
if (f1 >0&& f2 > 0){
System.out.printf("G.C.F of %d and %d is %d", f1, f2, gcf(f1, f2));}
else{ System.out.print("Positive inputs only"); }
}
See more about C+ at brainly.com/question/25870717
