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
kompoz [17]
3 years ago
13

Problem 5. (Greatest Common Divisor) Write a program gcd.py that accepts p (int) and q (int) as command-line arguments, and writ

es to standard output the greatest common divisor (gcd) of p and q.
Computers and Technology
1 answer:
netineya [11]3 years ago
8 0

Answer:

The following are the program in the Python Programming Language.

#import system

import sys

#define function

def gcd(p,q):

 #check that q is equal to 0

 if(q==0):

   #then, it returns the output

   return p

 #it returns the common divisor

 else:

   return gcd(q,p%q)

#get the command-line input

x=sys.argv[1]

#get the command-line input

y=sys.argv[2]

#convert input into the integer

p=int(x)

#convert input into the integer

q=int(y)

#call and print the function

print(gcd(p,q))

Explanation:

<u>The following are the description of the program</u>.

  • Firstly, we import the required package and define a function 'gcd()', pass arguments 'p' and 'q' and inside the function.
  • Set the if conditional statement to check that the variable 'q' is equal to 0 then, it returns the value of 'q' and otherwise, it returns the greatest common divisor value.
  • Finally, we set two variables 'x' and 'y' in which we get input from the command line then, convert the input of the both variable into integer and store them in other variables 'p' and 'q', after all, call and print the following function.
You might be interested in
What formula would you enter in c4 that combines a4 and b4 to get a result like c2
Paul [167]

Available options

=A4&&B4

=A4&" "&B4

="A4"&""&"34"

=A4&""&B4

Answer:

=A4&""&B4

Explanation:

In a Microsoft Excel spreadsheet, to combine the content of two cells into another cell, a user will have to use the command &

Hence, in this case, given that there is no need to have any character or blank space in between the content of the starging cells, which is just A4 and B4, then we have the following technique

1. Select the cell C2

2. Input the command = or +, then select cell A4

3. Input the command &

4. Then select the cell B4

5. Click enter.

Therefore, the answer should appear as =A4&B4.

But from the available options, there is nothing like that, so we pick =A4&""&B4 because it gives the same outcome.

6 0
3 years ago
Convert the following as indicated : (120)10 = (?)2​
Nookie1986 [14]

Answer:

1111000

Explanation:

perform the following. write from right to left:

- is the number even? then write down a 0

- is the number odd? then write down a 1 and subtract 1

- divide by 2

- repeat until you reach 0.

So for 120:

120 is even, so write down a 0 and continue with 120/2=60

60 is even,  so write down a 0 and continue with 60/2=30

30 is even,  so write down a 0 and continue with 30/2=15

15 is odd,  so write down a 1 and continue with 14/2=7

7 is odd, so write down a 1 and continue with 6/2=3

3 is odd, so write down a 1 and continue with 2/2=1

1 is odd, so write down a 1 and finish with 0

4 0
2 years ago
The property that allows a metal to be drawn into wires is called...
GaryK [48]

Answer:

Malleability and ductility

Explanation:

Metals are also easily distinguished from non-metals and other materials in their ductility (ability to be drawn into a wire) and malleability (the ability to be beaten into a. sheet).

Did you need help on this with an assignment? Hope this helps!

6 0
2 years ago
A sandbox is known as a holding area for website or .
Bingel [31]

Answer:

blog

Explanation:

7 0
2 years ago
Read 2 more answers
Write a loop that displays all possible combinations of two letters where the letters are 'a', or 'b', or 'c', or 'd', or 'e'. T
Dafna11 [192]

Answer:

for (char outerChar='a'; outerChar<='e'; outerChar++){

for (char innerChar='a'; innerChar<='e'; innerChar++){

cout << outerChar << innerChar << "\n";

}

}

3 0
2 years ago
Other questions:
  • Which of the four basic functions of a computer refers to the collection of data by a computer?
    11·2 answers
  • Which of the following declares an abstract method in an abstract C++ class? (Points : 2) public: void print();
    14·1 answer
  • You would like to put the data in order by product number. What should you do?
    15·1 answer
  • A(n) _____ describes your core values and highest career goals. A. résumé B. objective statement C. qualifications profile D. pe
    7·2 answers
  • Given that Apache and Internet Information Services (IIS) are the two most popular web application servers for Linux and Microso
    10·1 answer
  • Which area of study involves microeconomWhich area of study involves microeconomics? A. a nation's ability to meet consumer dema
    10·1 answer
  • The TCP _____ is the amount of information that a machine can receive during a session and still be able to process the data.
    5·1 answer
  • Jill is configuring the AutoArchive feature in Outlook 2016. What is the default setting in relation to when AutoArchive
    8·1 answer
  • True or false. The send e-mail feature, listed under tools, will allow you to send an e-mail to your instructor and to fellow st
    7·1 answer
  • What is the definition of Graphic AIDS?.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!