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]
4 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]4 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
Jnhj hjibfnufnbfjbnkfv fj v
kirill [66]

Answer: baller.

Explanation:

6 0
3 years ago
Write a program to read a sentence which is a single string. Then count the number of words in the sentence. The program will re
patriot [66]

Answer:

The program in Python is as follows:

sentence = input("Sentence: ")

words = len(sentence.split())

print("Words:", words)

Explanation:

This reads the sentence for the user

sentence = input("Sentence: ")

This counts the number of words

words = len(sentence.split())

This prints the number of words

print("Words:", words)

6 0
3 years ago
Tsunami warning systems that utilize satellite technology to send an alarm have recently been developed and installed. these sys
guapka [62]
The answer that would best complete the statement above would be option A. Tsunami warning systems that utilize satellite technology to send an alarm have recently been developed and installed and these systems are one example of how <span>technology and communication networks can impact global issues. Hope this helps.</span>
4 0
3 years ago
A hard drive that uses fde is often referred to as a(n) ____.
Sergio039 [100]

FDE stands for full disk encryption. FDE encrypts data as it is written to the disk and decrypt data as it is read off the disk. It is the simplest method of deploying encryption ,transparent to applications, databases, and users.

A hard drive that uses FDE is often referred to as a self-encrypting hard drive. correct answer: B

6 0
3 years ago
A(n) ________ is a light-sensitive material used to make a chip.
RSB [31]
The photoresist is a light-sensitive material used to make a chip. Photoresists can likewise be uncovered by electron shafts, creating an indistinguishable outcomes from introduction by light. The primary distinction is that while photons are consumed, storing all their vitality without a moment's delay, electrons store their vitality bit by bit, and scramble inside the photoresist amid this procedure.
3 0
4 years ago
Other questions:
  • A ________ is a system of hardware and software that stores user data in many different geographical locations and makes that da
    14·1 answer
  • Which signal types are represented by a continuous waveform?
    10·1 answer
  • What port does the DarkComet malware listen on?
    15·1 answer
  • 7x+ 2x = 14<br>want is (x)?​
    15·1 answer
  • (03.05 LC) Match the term with its description. (4 points) Column A 1. Acid : Acid 2. Alkaline : Alkaline 3. pH : pH 4. Ion : Io
    8·1 answer
  • PLEASE HELP ASAP IT'S DUE TODAY! WILL GIVE BRAINLIEST, FIVE STARS, AND THANKS!! PLEASE HELP!
    12·1 answer
  • What is employee Internet management (EIM) software?
    5·2 answers
  • What types of projects require collaboration? en360
    15·1 answer
  • PLEASEEEE HELPP ILL MARK BRAINLIEST!! in a presentation outline, each slide must represent a main point in the outline. true or
    5·1 answer
  • List 4 criteria of power your house with wind
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!