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
dem82 [27]
3 years ago
8

For two integers m and n, their GCD(Greatest Common Divisor) can be computed by a recursive function. Write a recursive method g

cd(m,n) to find their Greatest Common Divisor. Once m is 0, the function returns n. Once n is 0, the function returns m. If neither is 0, the function can recursively calculate the Greatest Common Divisor with two smaller parameters: One is n, the second one is m mod n. Although there are other approaches to calculate Greatest Common Divisor, your program should follow the instructions of this question, otherwise you will not get the credit. Then write a testing program to call the recursive method.
Computers and Technology
1 answer:
konstantin123 [22]3 years ago
6 0

Answer:

In Python:

def gcd(m,n):

if n == 0:

 return m

elif m == 0:

    return n

else:

 return gcd(n,m%n)

Explanation:

This defines the function

def gcd(m,n):

If n is 0, return m

<em> if n == 0: </em>

<em>  return m </em>

If m is 0, return n

<em> elif m == 0: </em>

<em>     return n </em>

If otherwise, calculate the gcd recursively

<em> else: </em>

<em>  return gcd(n,m%n)</em>

<em />

<em>To call the function to calculate the gcd of say 15 and 5 from main, use:</em>

<em>gcd(15,5)</em>

You might be interested in
You must _____ the recording of the macro when you have completed the tasks it was designed to do
Julli [10]
You must stop the recording.
8 0
3 years ago
All mortgage companies are willing to loan anyone money regardless of credit scores. True or false?
alina1380 [7]

Your credit reports and scores will be taken into consideration by lenders when deciding whether you qualify for a loan and what interest rate to offer you.You can have problems getting a loan if your credit report contains mistakes.So, check your credit right away.

Should you check your credit score before applying for a mortgage?

  • Although a credit score as low as 500 may be acceptable, there are still a number of other conditions to be met before you can receive an FHA loan guarantee.
  • Mortgage insurance, a 10% down payment (or 3.5% if your credit score is above 580), and a monthly payment are all requirements for these loans.
  • When you apply for a traditional loan, it is advised that your credit score be 620 or above.
  • Lenders may not be able to approve your loan or may be forced to offer you a higher interest rate, which could mean higher monthly payments, if your credit score is below 620.
  • A higher score may make you eligible for lower mortgage interest rates and fees because it gives a lender more assurance that you will make payments on time.
  • If you have a great credit score, some lenders may also lower their down payment requirements.
  • By comparing interest rates and costs from lenders who offer loans made for consumers with weak credit, you can obtain a loan despite having a low credit score.
  • And even better, think about repairing your credit before you apply for a loan so you may get better conditions.

       To learn more about mortgage refer

     brainly.com/question/1318711  

      #SPJ1

7 0
1 year ago
What is a cell? how is it referred?​
Ugo [173]

Answer:

A cell is defined as that source of current electricity which converts chemical energy into electrical energy.

hopefully this was helpful.<3

6 0
3 years ago
Plzzzzzzz help good answers only and best answer gets brainly
djverab [1.8K]

Answer:

Desmos (colab w/h math antics) , Calendar, Quizlet (colab w/h google) , Quizizz (colab w/h quizlet) , Kahoot (colab w/h google) , or Google Translate

7 0
4 years ago
Write a program that asks a user to roll a single die twice to get a sum value of 7. If the sum is 11, the user loses. If the su
barxatty [35]

Answer:

Check the explanation

Explanation:

#include <stdio.h>

int dice1;

int dice2;

int sum;

int roll_die_twice(int dice1,int dice2){

 

if(sum==7){

printf("winner");

 

}

else if (sum==11){

printf("looser");

}

else if (sum!=7 && sum!=11)

{

printf("nor winner or looser");

 

}

}

int main()

{

roll_die_twice(2,7);

return 0;

}

The code screenshot and code output can be seen in the attached image below.

6 0
4 years ago
Read 2 more answers
Other questions:
  • A video game character prefers to take enemies on from a distance. What skills might such a character have?
    11·2 answers
  • When Twitter is used to gather a large group for a face-to-face meeting it is called a
    10·1 answer
  • Using data from the BITS database, define a view named TopLevelClient. It consists of the number, name, address, balance, and cr
    9·1 answer
  • Which model represents scenarios thatchange over time?
    8·1 answer
  • 10 disscused reasons why organisatoions use electronic spreedsheet​
    14·1 answer
  • What is the difference between word processing software and email?
    12·2 answers
  • Use the drop-down menu to correctly identify the numbering system.
    7·1 answer
  • Select the items below that are examples of things that could use the smart card technology.
    7·1 answer
  • Consider some of the widespread global issues that we face here on Earth and briefly describe them. Then, choose one of the spac
    8·1 answer
  • Area Triangolo Rettangolo in c++
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!