• In determining the GCF of 3 and 1, case I applies because 3 is evenly

divisible by 1. The GCF of 3 and 1 is 1, and therefore the GCF of 7 and 3

is also 1.

hots

(a) The gcf method returns the greatest common factor of

parameters a and b, as determined by case I and case II. Write

the gcf method below. You are encouraged to implement this method

recursively

/** Precondition: a and b are positive integers.

Returns the greatest common factor of a and b, as described in part (a).

*/

public static int gcfint a, int b)

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])); }

   }

Ver imagen MrRoyal

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

Ver imagen lhmarianateixeira