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
Assume you are a manager in the security department of a high-tech corporation. You are mentoring Mary, an entry-level network t
nadya68 [22]

Answer:

Seek a bachelor's degree.

Explanation:

Seems more compromised and education from people with experience already.

6 0
3 years ago
Como interactua el hardware de la computadora con el ser humano
soldi70 [24.7K]

Answer:

Los humanos interactúan con las computadoras a través de una interfaz de usuario

7 0
3 years ago
Two types of are desktop computers and notebook computer
aalyn [17]

Explanation:

A. personal computer

wait others answer for sure

4 0
3 years ago
Read 2 more answers
You are starting a small web hosting business and
Studentka2010 [4]

Answer:

otp

Explanation:

don't know bro ask to your teacher

7 0
3 years ago
What best compares potrait and landscape orientations
REY [17]
In portrait  the height is taller than its wide and in landscape the height is smaller than wide
so its the wider and taller
5 0
3 years ago
Other questions:
  • Why do you think LinkedIn has become so popular?
    6·1 answer
  • The combination of two or more technologies or data feeds into a single, integrated tool is referred to as a _____.
    7·1 answer
  • Twitter is an example of a __________. social bookmarking website social tagging website microblogging website blogging website
    12·1 answer
  • What is the protocol that is used between a web browser and web server at the transportation layer?
    13·1 answer
  • A(n) __________ item is a hardware or software item that is to be modified and revised throughout its life cycle
    10·1 answer
  • Which of the following is one of the options available on the Columns menu on the
    6·1 answer
  • Array testGrades contains NUM_VALS test scores. Write a for loop that sets sumExtra to the total extra credit received. Full cre
    11·1 answer
  • Similarities between inline css and internal css​
    6·1 answer
  • MEOWWWWWRARRARARARARRA
    5·1 answer
  • How has 5G become more energy efficient?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!