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
icang [17]
3 years ago
14

Write a C++ function using recursion that returns the Greatest Common Divisor of two integers. The greatest common divisor (gcd)

of two integers, which are not zero, is the largest positive integer that divides each of the integers. For example, the god of 8 and 12 is 4.
Computers and Technology
1 answer:
kifflom [539]3 years ago
8 0

Answer:

The function is as follows:

int gcd(int num1, int num2){

   if (num2 != 0){

      return gcd(num2, num1 % num2);}

   else {

      return num1;}

}

Explanation:

This defines the function

int gcd(int num1, int num2){

This is repeated while num2 is not 2

   if (num2 != 0){

This calls the function recursively

      return gcd(num2, num1 % num2);}

When num2 is 0

   else {

This returns the num1 as the gcd

      return num1;}

}

You might be interested in
Health informatics is an interdisciplinary field which incorporates theory and methodology from fields in computer science. True
noname [10]

Health informatics is an interdisciplinary field which incorporates theory and methodology from fields in computer science is True.

True

<u>Explanation:</u>

To capture patient health information they used interdisciplinary field which is consists patient information and they diseases and cure treatment taken for that patient. All information is store in digital formatted.

The patient information is stored such as health informatics, nurse and doctor treatment, health treatment, medicine details, clinics information.

Health informatics are used to do further analysis on patient health. Doctors are using this information for their further treatment for their patient also.

Information are also can be used as IOT information so that patient information are readily available.

3 0
4 years ago
A cookie recipe calls for the following ingredients: • 1.5 cups of sugar • 1 cup of butter • 2.75 cups of flour The recipe produ
True [87]

The program that asks the user how many cookies they want to make and then displays the number of cups of each ingredient is corresponds to the ingredients mentioned above.

<h3>Further explanation</h3>

Python is a general-purpose programming language. We want to write a python program that asks the user how many cookies they want to make and then displays the number of cups of each ingredient.

48 cookies = 1.5 cups of sugar + 1 cup of butter + 2.75 cups of flour, so:

def main():

   cookies = float(input("How many cookies would you like to make?\n>"))

   sugar = (1.5 * cookies) / 48.0

   butter = cookies / 48

   flour = (2.75 * cookies) / 48

   print("To make ", cookies, " cookies, you will need:\n", \

         format(sugar, '.2f'), " cups of sugar\n", \

         format(butter, '.2f'), " cups of butter\n", \

         format(flour, '.2f'), " cups of flour", sep='')

   redoQuery()  

def redoQuery():

   yn = input("Would you like to check another batch size? (y/n)\n>")

   if yn == 'y':

       main()

   elif yn =='n':

       exit()

   else:

       print("Please enter only a lowercase \'y\' or lowercase \'n\'," \

             "then press enter")

       redoQuery()

main()

The run program is shown in the attachment below.

<h3>Learn more</h3>

1. Learn more about python https://brainly.in/question/8049240

 

<h3>Answer details</h3>

Grade:  9

Subject: Computers and Technology

Chapter:  programming with python

Keywords: python

4 0
3 years ago
Which of the following command-line utilities allows to test the reachability of a host across an IP network?
lesya692 [45]

Answer:PING

Explanation:The ping command is a command that can be used on the command line interface of your computer to verify that a computer can communicate over the network with another computer. it works by inputing ping command with host name address( IP address)and proceeding with enter button to get output.

8 0
3 years ago
Discard an old computer and want to erase my files
Tamiku [17]
You can use a program like SafeErase to wipe all of your data throughly off your computer. 
7 0
3 years ago
KSJEDHGYGVWJHMJ,RHGFYDOYWUGWHBJK
Sophie [7]

Answer:

hmmm this seems sophisticated.

Explanation:

4 0
3 years ago
Other questions:
  • Using the flowchart below, what value when entered for Y will generate a mathematical error and prevent our flowchart from being
    14·1 answer
  • Building relationships during your career exploration is called
    9·2 answers
  • Can you block someone on Brainly?
    7·2 answers
  • This may vary in your state, but S/P2 recommends keeping all environmental documentation a minimum of:
    13·2 answers
  • PLS ANSWER ASAP!
    9·1 answer
  • Which line of code will only allow a symbol to be stored in a variable?
    11·2 answers
  • Write a program that prompts the user to enter a grade, which is aninteger in the range of 0 - 100. Using if statements, have th
    11·1 answer
  • A data analyst adds descriptive headers to columns of data in a spreadsheet. How does this improve the spreadsheet?.
    8·1 answer
  • Why is it important to register your software when you install it
    15·1 answer
  • If html is used to specify the content of the webpage, then what do you use css for?.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!