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
(tco 3) what vbscript boolean operator could be used to replace the nested selection structure in this pseudocode? if empmedical
Leto [7]
You want both conditions to be true, so you can "And" them.
In vbscript, the and is written as "And" (not as && like other languages), so you get:

<span>If (empmedicalins = "y") And (empdentalins = "y") Then
    print empidnumber, emplastname, empfirstname
Endif</span>
3 0
3 years ago
A college meal plan allows students to:
Wittaler [7]

Answer:

I think it's B.

Explanation:

You have to pay upfront for the types of meals you want. It will be different now though, because the Corona virus.

6 0
4 years ago
Read 2 more answers
Pleaseee help me with the typical situations of the icons(i already know for words but I have no idea for giving the situations
Aliun [14]
Send the icons so i can answer
4 0
2 years ago
¿Cuál fue el invento que revolucionó en la edad media?
9966 [12]

Answer:

I don't know...................

7 0
4 years ago
I will mark brainillist if someone answers Donethkm question its How can a Word user insert a page break into a document to isol
zloy xaker [14]

Answer:

Open the dialog box.

Select the tab.

Select the tab.

Explanation:

cause

8 0
4 years ago
Read 2 more answers
Other questions:
  • Which is NOT a way the network operating sys-
    6·1 answer
  • Which of the following statements is correct? A. The columns will be listed in the results in the same order they are stored in
    7·1 answer
  • Rachel wants to post content from digital cameras on the web. Which online tool will help Rachel to post and edit content on a w
    5·1 answer
  • Which of the following best describes the displayport interface used for connecting video monitors to computers
    11·1 answer
  • Which button should be utilized if a user is unsure whether or not they are the right person to reply to an email?
    6·2 answers
  • Why is know app downloading in my android phone even if I have 900 MB ???
    8·2 answers
  • What if the result of conectivity testing is 100%Loss?Explain.​
    14·1 answer
  • Give five example of secondary storage device, stating their function and storage capacity​
    6·1 answer
  • Write a program that reads 20 integers from the user into an array and uses a function arrayMinimum that accepts an integer arra
    5·1 answer
  • Usually it is a rectangular box placeed or underneath your desk​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!