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
4
kupik [55]

Answer:

the answer is D Smart Object

5 0
3 years ago
Read 2 more answers
What does coding mean​
NeTakaya
The process or activity of writing computer programs.
3 0
3 years ago
Read 2 more answers
I can’t wait Till Miya’s anniversary skin To be released on september 21st
dezoksy [38]

Answer:

no u

Explanation:

no need

3 0
3 years ago
I know this is not a school type question but i really need some help.
pashok25 [27]
If I'm not mistaken u can't do that but u can go in your settings if u have an iPhone and add that email with your main one.
8 0
4 years ago
How has social media changed professional networking?
fenix001 [56]

Answer:

It enables and allows to stay people in touch with other globally.

Explanation:

7 0
3 years ago
Other questions:
  • What is the name for the individual sections of the ribbon in PowerPoint 20162
    8·1 answer
  • Help Asap! Marking brainliest!✨
    15·2 answers
  • Give two separate print statements: one will print your name, the other will print your major. Ensure that both will print on th
    15·1 answer
  • If a tv was showing a flat black or blue screen or had "snow", what steps would you take to fix it? Give an example of the direc
    11·1 answer
  • What is the value of the result after the following statement is executed? int result = 2 + 3 + 4 ;
    7·1 answer
  • Several NEC® sections contain the requirement to size conductors and overcurrent devices at 100 percent of the noncontinuous loa
    15·1 answer
  • What feature sets Macs apart from other operating systems?
    5·1 answer
  • Guess The Song:
    9·1 answer
  • What do you hope that people see in your digital footprint 5 years from now? ​
    5·1 answer
  • How did transistors revolutionize the world of computers?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!