1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
frutty [35]
3 years ago
7

The greatest common divisor of integers x and y is the largest integer that evenly divides into both x and y. Write a recursive

method gcd that returns the greatest common divisor of x and y. The gcd of x and y is defined recursively as follows: If y is equal to 0 then gcd(x,y) is x; otherwise gcd(x,y) is gcd(y,x%y), where % is the remainder operator
Computers and Technology
1 answer:
Virty [35]3 years ago
4 0

Answer:this is made in java programing language

Program:

/**********************************************************

* The following GreatestCommonDivisor class demonstrates *

* a method called gcd. It reads two integers from the user*

* and displays the GCD of two integers. The method gcd *

* calculates and returns the GCD of two integers. *

**********************************************************/

// GreatestCommonDivisor class

import java.util.Scanner;

public class GreatestCommonDivisor

{

// start main main method

public static void main(String[] args)

{

// declare variables

int firstInteger;

int secondInteger;

int gcdOfTwoIntegers;

// create an object for Scanner class

Scanner input = new Scanner(System.in);

Prompt the user to enter the two positive integers.

// prompt the user to enter the first integer

System.out.print("Enter the first positive integer: ");

firstInteger = input.nextInt();

// prompt the user to enter the second integer

System.out.print("Enter the second positive integer: ");

secondInteger = input.nextInt();

Call the gcd method to get the greatest common divisor of two integers.

// call gcd method to get gcd of two integers

gcdOfTwoIntegers =

gcd(firstInteger, secondInteger);

Display the greatest common divisor of two integers.

// display the gcd of two integers

System.out.println("The GCD of " + firstInteger + " and " + secondInteger +

" is " + gcdOfTwoIntegers);

} // end of main method

The following gcd method accepts two integers as its parameters. It finds and returns the greatest common divisor of these integers recursively.

// gcd method implementation

public static int gcd(int x, int y)

{

// verify whether the value of y is zero or not

if(y == 0)

// return x if the value of y is zero

return x;

else

/* call gcd method recursively if the value of y is non-zero */

return gcd(y, x % y);

} // end of gcd method

} // end of GreatestCommonDivisor class

Explanation:

You might be interested in
When microsoft released word for windows, wordperfect had about 80 percent of the word processing market. microsoft donated free
irina1246 [14]

When Microsoft donated copies of Word program to colleges and universities, the company Microsoft is using a Marketing Strategy in promoting the product. A good promotion will help the product to be known and by words of mouth it will basically promote the product and the users will definitely give comments on how the product performs.

7 0
3 years ago
Which recorder is least recommended in automation anywhere?
raketka [301]
<h2>Answer:</h2>

<u>Screen recorder</u><u> is the least recommended one</u>

<h2>Explanation:</h2>

There are three types of recorders. They are Smart Recorder, Web Recorder and Screen or sometimes called Standard Recorder. Smart Recorder is used for desktop applications while Web recorder is used for Web-based applications. The least recommended one is Screen Recorder which is used for building simple tasks that involves few mouse clicks and keystrokes. It works by capturing screen co-ordinates and therefore, no calibration is taken into account. It is generally used when you plan to run the task on the same machine on which, it was recorded.

4 0
3 years ago
Read 2 more answers
Can someone please tell me how to download tor browser onto a Linux laptop?
marta [7]

Answer:

Use windows

Explanation:

7 0
2 years ago
Why are hardline Ethernet connections always faster than WiFi?
Bumek [7]
Because Ethernet uses cables, it tends to work slightly faster than a wireless connection. Wireless connections are a bit slower, but provide the convenience of using it within range. Today, WiFi hotspots can easily be found in many places. Thus, the choice lies between speed and convenience.
Wi-Fi vs. Ethernet: Which Connection to Use?
by Allen Jame
3 0
3 years ago
Drag the tiles to the correct boxes to complete the pairs.
Monica [59]

Answer:

refers to how much black or white color contains: value,defines a range from dark (0%)to fully illuminated (100%):lightness, Express the brightness or dullness of a color:intensity ,stands for a pure color:hue

HOPE THIS HELPS

8 0
3 years ago
Other questions:
  • How useful do you find the creation of folders in your computer?
    8·2 answers
  • Why would an IT technician ever have to change out a computer’s motherboard?
    5·2 answers
  • Briefly summarize two examples of cybercrime stories.<br> quick pleaseeee
    10·1 answer
  • Which of the following are tasks you can
    12·2 answers
  • Precautionary measures to be observed when using ICT tools​
    15·1 answer
  • 3.
    5·1 answer
  • SOMEONE PLEASE HELP ME I REPOSTED THIS 3 time and no ONE HAD HELPED ME
    15·1 answer
  • What is the school wifi password trying to do my class work in school on different devices.
    9·1 answer
  • HOW TO GET RID OF THESE LINES?? PLS WILL GIVE BRAINLIEST
    8·2 answers
  • 9.18 lab: even/odd values in a vector write a program that reads a list of integers, and outputs whether the list contains all e
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!