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
Should the use of hacktivists by a country against enemy organizations be considered an act of war? Why or why not? How about th
Artyom0805 [142]

Explanation:

Hacktivist comes from the combination of two words --- "Hack" and " Activism" .

Hacktivist perform hacktivism that means they make use of technology and knowledge to support as well as promote the political agenda and any kind of change in the social event.

Cyberterrorism, on the other hand uses internet and technology and conduct terrorism and other anti national activities like to coerce the societies or the governments in pursuit of their goals which are  religious, ideological or political.

While Hacktivism is used for a political cause, and is done in a peaceful manner; whereas cyber terrorism tries to grab the attention of the public through their aggressive ways, specifically by putting fear among the public.

But there is no instance of any person of getting killed by a cyber-attack or cyber terrorism. The larger damage is however done by those viruses or malware which gets into other persons computers or enemy organization computer system and weakens them and steals information and data. They damage and harm the economy in a larger scale.

When Chinese government first introduced the Trojan virus on the computer systems of their opponents abroad, is that can be called as Hacktivism? In  essence, this act may be called as cyber terrorism and not hacktivism. Because the Chinese Government intend to cause major economic damage and harm to their opponents or enemy organization by targeting the software giants in the West.

These companies crashed and and many left jobless and unemployment, they caused economic problems and damage to the technologies.  However, the Chinese Government's perspective on this is that they addresses such a thing as hacktivism as it advocates the state censorship by filtering the politically or the socially-unacceptable ideas in their e-mail.

Thus, the answer is relative as to whose perspective we are looking. Either we are taking the perspective of the Chinese government or that of the enemy organization which is affected by the act of the state censorship and targeting the Western software giants.

Cyberterrorism will somehow become a serious threat to the society when people adept at hacking will sympathize and also align with terrorists activities and cause. It has become appealing since some of computer programs have the features that are easily exploited and conducive for committing cyber terrorism.

3 0
3 years ago
To discover how many cells in a range contain values that meet a single criterion, use the ___ function
alexandr402 [8]

Answer:

COUNTIF

Explanation:

the Countif function counts the number of cells in range that meets a given criteria.

6 0
3 years ago
____________________________ and _________________________ are 2 positive impacts of the internet on businesses.
ZanzabumX [31]
D improved comms and easy ads
4 0
3 years ago
Read 2 more answers
A corporate or government network that uses Internet tools, such as Web browsers, and
Alchen [17]

Answer: Intranet

Explanation:

The options include:

A. extranet.

B) social network.

C) intranet.

D) e-market.

A corporate or government network that uses Internet tools, such as Web browsers, and Internet protocols is referred to as intranet.

Social networks are social media sites that are used by people which allows them to stay connected with one another.

E-market is a form of marketing whereby goods and services are promoted or advertised through the use of the internet.

Therefore, the answer to he above question is intranet.

3 0
3 years ago
In this scenario, what is the importance of anti-virus software and other similar virus protection programs?
Svetradugi [14.3K]
To protect my computer form hacking and save my files
3 0
3 years ago
Other questions:
  • Holly Carpenter argues that technology may actually prevent some kinds of evolution that would benefit humans. Do you agree with
    8·2 answers
  • Which information is necessary to determine an object's speed?
    13·1 answer
  • Which of the following payment types require you to pay upfront A. Money order and credit card B. Money orders and prepaid card
    9·2 answers
  • How do you change your age on here? I accidentally put that i was 15 but i am only 13. How do I change this?
    12·1 answer
  • What is the output of the following code segment? int n = 0; for (int k = 0; k&lt; 2; k++) {n=n +2;} cout &lt;&lt; n; oo 0 1 O O
    8·1 answer
  • As a general rule, the number of bullet points on a slide should not exceed _____. a.2 b.4 c.8 d.10
    9·1 answer
  • Xxx<br>uuuuuu<br>uuuu<br>jjnmn<br>jjh
    12·1 answer
  • ---------------------- use of the Internet to access programs and data on computers that are not owned and managed by the user o
    9·1 answer
  • You looked at the methods used to determine database requirements. Now, research and find a database requirements template. Choo
    9·1 answer
  • A manager suspects that one of his team members has been fraudulently accessing confidential and sensitive information and breac
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!