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
What does the CMYK tab let you do
Paha777 [63]

<span>CMYK means cyan, magenta, yellow, and key (black). They are the four color model used in color printing or printing color images. It lets you subtract the colors on the image. CMYK partially or fully masks colors on a lighter view. </span>

3 0
3 years ago
Read 2 more answers
Which are the benefits of leveraging web technologies?
allsm [11]

Lower cost - You can leverage web technologies like FB and Google which allow you to advertise and reach billions of users relying on their services at a very low cost as compared to other mediums.  

Security – Data stored with web technology companies offers more security because it is stored in huge data centers that have high-end protection

Increase business efficiency – Web technologies can increase business efficiency and unlock value in your business functions. They can reduce time, provide critical analytics and help your business grow.

4 0
4 years ago
Read 2 more answers
Why do companies send updates to devices
Luden [163]
To ensure that they are up to date and running smoother than before. Withought updates our devices wouldnt work properly the way they are supposed to!
3 0
4 years ago
Complete the code.
Dmitrij [34]

<u>Answer</u> : Float

<u>Explanation</u> :

Complete the code.

import csv

inFile = open ("one.txt","r")

outFile = open("another.txt", "w")

myReader = csv.reader(inFile)

for item in myReader:

aWord = item[0]

aNumber = float(item[1]) + 0.4

line = aWord + "," + str(aNumber) + 'Float'

outFile.write(line)

3 0
3 years ago
Who is better Michealangelo the ninja turtle or Speed Slaver the car This is part of a survey that I need for work.
Pie

Answer:

Michealangelo

Explanation:

Such a classic who can argue

7 0
4 years ago
Read 2 more answers
Other questions:
  • Which data type uses more memory an integer or an unsigned integer?
    6·1 answer
  • Hanging out with friends, watching your favorite TV show, and buying a pair of new shoes are all examples of _____ for doing wel
    5·2 answers
  • ______ devices are high-performance storage servers that are individually connected to a network to provide storage for the comp
    5·1 answer
  • What translates binary data into images on a monitor?
    8·1 answer
  • The small company where you work needs to implement a second server for its accounting system, but does not have the funds to pu
    11·1 answer
  • Students working at individual PCs in a computer laboratory send their files to be printed by a server that spools the files on
    13·1 answer
  • Overview of your opinion of Digital Etiquette
    10·1 answer
  • In this assignment, you will implement an online banking system. Users can sign-up with the system, log in to the system, change
    14·1 answer
  • In response to an alert regarding a possible security incident, you are analyzing the logs for a web application. In the process
    13·1 answer
  • Write a program that passes an unspecified number of integers from command line and displays their total. Sample Run 1 command&g
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!