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
A group of accountants encrypt the emails they send to your company because they contain highly sensitive financial information.
ratelena [41]

Answer:

a) Generate a new public and private key

Explanation:

You encrypt a message using the recipient's public key and the recipient decrypts the message using his own private key. Only the public key can be known by an external agent. The private key is for the individual and is not expected to be shared. In the event that the recipient cannot decrypt the message, it is unsafe to send one's private key to him. He does not even need one's private key to decrypt the message, he needs his own private key.

The best thing to do is to generate another means of security by generating new public and private key so that the sender encrypts the message with the new public key and the receiver decrypts it using his new private key.

Option B is wrong because, if the encryption is removed, the aim, which is to secure the message from intruders is not achieved.

8 0
2 years ago
A type of bridge that relies on a curved, semi-circular structure for support
inna [77]
Arch bridges have a semicirclar, curved support.
8 0
3 years ago
¿Qué creo que debe considerar una empresa para elegir ellugar en el cual va a desarrollar su actividad económica osu emprendimie
zhannawk [14.2K]

Answer:

sorry I don't speak that language

8 0
2 years ago
Hi! This is python coding. Please don't take advantage, actually, answer!
Greeley [361]

Answer:

Try and do number = 7

If that does not work then I dont know what to tell you.

Explanation:

8 0
3 years ago
Ill give 100 points to whoever gives me the CORRECT answer. I keep getting syntax errors when I do the "add:" part. Can someone
Olin [163]

Answer:

sorry but there is not enough information to complete this

Explanation:

6 0
2 years ago
Read 2 more answers
Other questions:
  • User accounts will be locked out after authentication is attempted
    7·1 answer
  • Match the following.
    8·2 answers
  • Read each statement below. If the statement describes a peer-to-peer network, put a P next to it. If the statement describes a s
    13·2 answers
  • Janice, who is 15, posts a picture of herself drinking alcohol and making an obscene gesture on her social networking page. Whic
    11·2 answers
  • The picture that graphically represents the items you use in windows is called a/an
    5·1 answer
  • In Java, it is possible to create an infinite loop out of while and do loops, but not for-loops. true or false
    11·1 answer
  • A program that will read each player’s name and golf score as keyboard input,
    9·1 answer
  • Individual internet users connect to isps through a(n ________.
    11·1 answer
  • ________ was one of the first uses of the Internet
    15·2 answers
  • According to Chargaff's data, ________ must pair with ________, and ________ must pair with ________.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!