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
2023 murano’s available intelligent awd adjusts the ________ to help maintain cornering control.
Andrews [41]

2023 Murano's available intelligent awd adjusts the Torque delivered to the wheels to help maintain cornering control.

<h3>How does torque moves wheels?</h3>

The torque from the engine is known to be that tool that moves a car. A lot of torque can be transferred to the wheels in first gear and it is better than in fifth gear.

Hence, 2023 Murano's available intelligent awd adjusts the Torque delivered to the wheels to help maintain cornering control.

Learn more about cornering control from

brainly.com/question/17371984

#SPJ1

7 0
2 years ago
As computer words get larger and larger, there is a law of diminishing returns: the speed of execution of real application progr
otez555 [7]

Answer:

Explanation:

I can pick a reason out of many, and that would be the software. The fact is that, even as they are computers and machines, the softwares themselves have particular design cap. A software that was designed for systems with a narrow word size will most likely have issues as more and more words are used on it. I don't know if you understand what I'm saying, everything has a cap, once that particular meter is approaching, systems tend to slow onwards.

When it comes to the hardware part using the same technology, it might take a longer time to do basic arithmetic on larger inputs.

When you're under using a system, it tends to have a lot of space, excess, to perform its functions, but as soon as it is nearing its limit, it will slow down so as to accommodate all the processes at once.

3 0
3 years ago
To insert a footnote in a document, a user would navigate to the _____ tab.
Pachacha [2.7K]

Answer

References tab.

Explanation

In MS word documents, you can add footnotes and endnotes by;

• Clicking the area to add a footnote

• Clicking references, then insert Footnote. The word program will insert a reference mark in the text and will add the footnote mark at the bottom of the page

• Type a footnote text.

Hope this Helps!

3 0
3 years ago
Read 2 more answers
Hawaii and japan are examples of islands made by? You have to write it.
Brums [2.3K]

Answer:

Volcanic activity

5 0
3 years ago
Read the PIC Data sheet Chapter 2.0 and 3.0 2. List at least 3 big differences between the Flash and RAM 3. How many RAM locatio
Alex Ar [27]

Answer: Incomplete question

Explanation: The question attached is incomplete and incoherent, possible solution of this will be difficult to assume. Take adequate time to post complete questions.

Regards.

4 0
3 years ago
Other questions:
  • a problem exists when the current condition differs from a desired condition. This idea defines which step in problem-solving?
    13·2 answers
  • In an ipv4 address, what are the maximum number of bits that can be used to identify the network address
    14·1 answer
  • _____ refers to unsolicited commercial emails, usually sent to a large number of people with little regard to the users interest
    14·1 answer
  • Ignorance of policy is a legal excuse for an employee. TRUE or FALSE
    11·1 answer
  • Which words in the sentence make up the adjective phrase? Which word does the adjective phrase modify? The farmer delivers five
    15·1 answer
  • Many Web browsers allow users to open anonymous windows. During a browsing session in an anonymous window, the browser does not
    14·1 answer
  • 8. _______ are used to store all the data in a database.
    7·2 answers
  • What does "scanf(\"%d\" mean?
    13·2 answers
  • What in the world is this for and how do you use it
    8·2 answers
  • H. What is recycle bin?<br>-&gt;​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!