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]
2 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]2 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
Javascript or java? which one is better?
kifflom [539]
See, one is more or less a toy, designed for writing small pieces of code and traditionally used and abused by inexperienced programmers. 

The other is a scripting language for web browsers. Sorry about my limited knowledge.
3 0
3 years ago
Read 2 more answers
Preciso de ajuda urgente, é para amanhã cedo!!
Papessa [141]


Bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
5 0
3 years ago
Question 7 of 25
Vika [28.1K]

Explanation:

the right answer may be A.

5 0
2 years ago
12. ______ is considered to be the first video game mascot.
Tatiana [17]
D pac man im hope im right
7 0
3 years ago
Lyla is using a computer repair simulator. This program can help her
tamaranim1 [39]

Answer:

D. Learn the different types of hardware.

Explanation:

When Lyla is a computer repair simulator, she is learning the different types of hardware. After she has learned most of the types of hardware, she can repair her computer.

hope this helped.

8 0
2 years ago
Read 2 more answers
Other questions:
  • What kind of testing is basically checking whether a game or feature works as expected by the developers?
    10·1 answer
  • Technician A says that to cover all possible vehicle conditions, coolant must have a high freezing point. Technician B says cool
    6·2 answers
  • What are personal skills?
    5·1 answer
  • . Write a short program that asks the user to input a string, and then outputs the
    15·1 answer
  • One of the best ways to shoot a picture is to frame the subject in the middle of the screen or viewer. T or F
    14·2 answers
  • WHO HAS TWITCH<br> PLS FOLLOW ME MY TWITCH IS giaplayzgamez I'm uploading Videos Soon.
    11·2 answers
  • Como se llaman las herramientas y maquinas pque utilizan para hacer cosas artesanales
    10·1 answer
  • If you want to change the name of a folder that stores Word documents, what should you do before changing the
    15·1 answer
  • Expressions provide an easy way to perform operations on data values to produce other data values. True False
    11·1 answer
  • B. WAP to check whether input number is palindrome number or not using SUB...... END SUB.​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!