Write a program with 2 separate functions which compute the GCD (Greatest Common Denominator) and the LCM (Lowest Common Multiple) of two input integers.

Answers

Answer 1

Answer:

The program written in Python is as follows

def GCD(num1, num2):

    small = num1

    if num1 > num2:

         small = num2

    for i in range(1, small+1):

         if((num1 % i == 0) and (num2 % i == 0)):

              gcd = i

    print("The GCD is "+ str(gcd))

def LCM(num1,num2):

    big = num2  

    if num1 > num2:

         big = num1

    while(True):

         if((big % num1 == 0) and (big % num2 == 0)):

              lcm = big

              break

         big = big+1

     print("The LCM is "+ str(lcm))

 print("Enter two numbers: ")

num1 = int(input(": "))

num2 = int(input(": "))

GCD(num1, num2)

LCM(num1, num2)

Explanation:

This line defines the GCD function

def GCD(num1, num2):

This line initializes variable small to num1

    small = num1

This line checks if num2 is less than num1, if yes: num2 is assigned to variable small

    if num1 > num2:

         small = num2

The following iteration determines the GCD of num1 and num2

    for i in range(1, small+1):

         if((num1 % i == 0) and (num2 % i == 0)):

              gcd = i

This line prints the GCD

    print("The GCD is "+ str(gcd))

   

This line defines the LCM function

def LCM(num1,num2):

This line initializes variable big to num2

    big = num2  

This line checks if num1 is greater than num2, if yes: num1 is assigned to variable big

    if num1 > num2:

         big = num1

The following iteration continues while the LCM has not been gotten.

    while(True):

This if statement determines the LCM using modulo operator

         if((big % num1 == 0) and (big % num2 == 0)):

              lcm = big

              break

         big = big+1

This line prints the LCM of the two numbers

     print("The LCM is "+ str(lcm))

The main starts here

This line prompts user for two numbers

print("Enter two numbers: ")

The next two lines get user inputs

num1 = int(input(": "))

num2 = int(input(": "))

This calls the GCD function

GCD(num1, num2)

This calls the LCM function

LCM(num1, num2)

See attachment for more structured program


Related Questions

A scared kangaroo clears a fence that is 2.44 meters tall. What is the vertical component of the kangaroos velocity at take off ? If the horizontal component of the kangaroos velocity is 4.80 m per s at what angle did the kangaroo take off the ground? (hint: at its maximum height the kangaroos vertical velocity is 0)

Answers

Answer:

a) The vertical component of the kangaroo's velocity at take off is approximately 4.982 meters per second.

b) The angle at which the kangaroo took off the ground is approximately 46.066º.

Explanation:

a) According to the statement, the kangaroo has an initial horizontal velocity and jumps to overcome the fence until velocity becomes zero. If effects from non-conservative forces can be neglected, then we represent the situation of the kangaroo by Principle of Energy Conservation:

[tex]K_{1}+U_{g,1} = K_{2}+U_{g,2}[/tex] (Eq. 1)

Where:

[tex]K_{1}[/tex], [tex]K_{2}[/tex] - Initial and final translational kinetic energies, measured in joules.

[tex]U_{g,1}[/tex], [tex]U_{g,2}[/tex] - Initial and final gravitational potential energies, measured in joules.

By definitions of translational kinetic and potential gravitational energies, we expand and simplify the equation above:

[tex]\frac{1}{2}\cdot m\cdot [(v_{1,x}^{2}+v_{1,y}^{2})-(v_{2,x}^{2}+v_{2,y}^{2})] = m\cdot g \cdot (y_{2}-y_{1})[/tex]

[tex]\frac{1}{2}\cdot [(v_{1,x}^{2}+v_{1,y}^{2})-(v_{2,x}^{2}+v_{2,y}^{2})] = g \cdot (y_{2}-y_{1})[/tex] (Eq. 2)

Where:

[tex]m[/tex] - Mass of the kangaroo, measured in kilograms.

[tex]g[/tex] - Gravitational acceleration, measured in meters per square second.

[tex]y_{1}[/tex], [tex]y_{2}[/tex] - Initial and final heights of the kangaroo above the ground, measured in meters.

[tex]v_{1,x}[/tex], [tex]v_{1,y}[/tex] - Vertical and horizontal initial velocities, measured in meters per second.

[tex]v_{2,x}[/tex], [tex]v_{2,y}[/tex] - Vertical and horizontal final velocities, measured in meters per second.

If we know that [tex]v_{1,x} = 4.80\,\frac{m}{s}[/tex], [tex]v_{2, x} = 0\,\frac{m}{s}[/tex], [tex]v_{2,y} = 0\,\frac{m}{s}[/tex], [tex]g = 9.807\,\frac{m}{s^{2}}[/tex] and [tex]y_{2}-y_{1} = 2.44\,m[/tex], then (Eq. 2) is reduced into this:

[tex]11.52+0.5\cdot v_{1,y}^{2}=23.929[/tex]

Lastly, we solve for [tex]v_{1,y}[/tex]:

[tex]0.5\cdot v_{1,y}^{2}=12.409[/tex]

[tex]v_{1,y}^{2} = 24.818[/tex]

[tex]v_{1,y} \approx 4.982\,\frac{m}{s}[/tex]

The vertical component of the kangaroo's velocity at take off is approximately 4.982 meters per second.

b) The angle at which the kangaroo took off the ground ([tex]\theta[/tex]), measured in sexagesimal degrees, is obtained by the following inverse trigonometric relation:

[tex]\theta =\tan^{-1}\left(\frac{v_{1,y}}{v_{1,x}} \right)[/tex] (Eq. 3)

[tex]\theta = \tan^{-1}\left(\frac{4.982\,\frac{m}{s} }{4.80\,\frac{m}{s} } \right)[/tex]

[tex]\theta \approx 46.066^{\circ}[/tex]

The angle at which the kangaroo took off the ground is approximately 46.066º.

Which class members should be declared as public?

a
Data attributes and constructor methods
b
Data attributes only
c
Methods and occasionally final attributes
d
Predominantly data attributes and some helper methods

Answers

Answer:

B. Methods and occasionally final attributes

Explanation:

In Computer programming, class members can be defined as the members of a class that typically represents or indicates the behavior and data contained in a class.

Basically, the members of a class are declared in a class, as well as all classes in its inheritance hierarchy except for destructors and constructors.

In a class, member variables are mainly known as its attributes while its member function are seldomly referred to as its methods or behaviors.

One of the main benefits and importance of using classes is that classes helps to protect and safely guard their member variables and methods by controlling access from other objects.

Therefore, the class members which should be declared as public are methods and occasionally final attributes because a public access modifier can be accessed from anywhere such as within the current or external assembly, as there are no restrictions on its access.

I need help with my homework:
Greetings, secret agent 00111! Your mission, should you choose to accept it, is to help Agent M plan a pizza party. Unfortunately, M has no idea how much pizza to order for his 83 guests. Luck for him, party planning is your specialty! Estimate the number of pizzas he’ll need on scratch paper, and then convert that number to binary and write it here.

Answers

Answer:

You need to order 11100 pizzas.

Explanation:

A couple of assumptions here.

Each pizza has 12 slices.  Each guest will eat 4 slices (1/3 of a pizza).

83 * 1/3 = 28 pizzas

28 = 11100

server.
10. The Domain Name refers to the
a) Mail
b) Google
c) Internet
d) Local

Answers

Answer:

C.

Explanation:

what is the CPU's role?

Answers

Answer:

The CPU performs basic arithmetic, logic, controlling, and input/output (I/O) operations specified by the instructions in the program. The computer industry used the term "central processing unit" as early as 1955.

Answer:

The Cpu is like the brain of the computer it's responsible for everything from running a program to solving a complex math equation.

how do you keep word from trying to capitalize every isolated letter "i"

Answers

Write "i" the write random words then delete it and add the lowercase i
Answer: It’s best to write the letter “i” then on the word suggestions, click “i” and repeat it a few times to let the phone register that you only want your individual “i” to be lowercase.

I need help plz it’s python

Answers

Answer:

The output of the first question would be 9. And the answer the second question is 10.

Active listening is not possible while taking notes during a lecture.


Please select the best answer from the choices provided

T
F

Answers

Answer: The answer is False

Explanation:

Active listening is not possible while taking notes during a lecture. The given statement is true.

What is the statement?

Statements are sentences that express a fact, idea, or opinion. Statements do not ask questions, make requests or give commands. They are also not utterances. Statements are sentences that express a fact, idea, or opinion. Statements do not ask questions, make requests or give speech acts. They are also not exclamations.

Choose a seat where you can hear and see well. In order to reduce distractions, turn off your cell phone. Have all of your supplies on hand, including your textbook, pens, and paper. Choose the method of taking notes that is most effective for the class you are attending.

You must at least partially complete the specified readings prior to any lecture. Your teachers will frequently remind you that this is crucial to understanding the course material (or having success in lectures).

Therefore, Active listening is not possible while taking notes during a lecture. The given statement is true.

Learn more about the statement here:

brainly.com/question/2285414

#SPJ6

Write a method that accepts two string arrays and print common values between the two arrays (Perform case sensitive search while finding common values).

Answers

Answer:

public class Main

{

public static void main(String[] args) {

 String[] s1 = {"Hi", "there", ",", "this", "is", "Java!"};

 String[] s2 = {".", "hi", "Java!", "this", "it"};

 findCommonValues(s1, s2);

}

public static void findCommonValues(String[] s1, String[] s2){

    for (String x : s1){

        for (String y : s2){

            if(x.equals(y))

                System.out.println(x);

        }

    }

}

}

Explanation:

*The code is in Java.

Create a method named findCommonValues that takes two parameters, s1 and s2

Inside the method:

Create a nested for-each loop. The outer loop iterates through the s1 and inner loop iterates through the s2. Check if a value in s1, x, equals to value in s2, y, using equals() method. If such a value is found, print that value

Inside the main method:

Initialize two string arrays

Call the findCommonValues() method passing those arrays as parameters

If a small cheap computer can do the same thing as a large expensive computer,
why do people need to have a large one?

Answers

Answer:

Large ones are for more important thing. Such as gaming and special software.

Explanation:

Hope that helps

Large systems are the ones that are for more important thing. Such as gaming and special software.

Why is the size of a computer Important?

Computer scientists and users value the classification of computers based on their size. It enables us to classify the computer system according to its size and processing capacity.

For gamers who desire the greatest possible gaming experience, expensive PCs are also wonderful.

You can play the most recent games smoothly and at high settings if you have a powerful computer. A costly PC also has the benefit of lasting longer than a less expensive model.

Most computer monitors have a diagonal measurement from corner to corner that falls between 19 and 34 inches. 22 to 24" screens will be sufficient for the majority of users.

Thus, it can be beneficial to use larger computers also.

For more details regarding computers, visit:

https://brainly.com/question/21080395

#SPJ2

HELP !!!
Which of the following statements best represents the difference in printing text and images in the era of moveable type?


Text was harder to print than images because it involved moving letters around for each line of print.

Text was created by arranging letter blocks, while images were created through an engraving process.

Text was created by engraving letter blocks on metal, while images were created by burning imprints onto wood.

Text was easier to print than images because it involved the same 26 letters used over and over.

Answers

Answer:

I think the answer is: Text was created by arranging letter blocks, while images were created through an engraving process.

Explanation:

in the article it explains these were the ways text and images were printed

Answer:

e

Explanation:

You are adding more features to a linear regression model and hope they will improve your model. If you add an important feature, the model may result in.
1. Increase in R-square
2. Decrease in R-square
A) Only 1 is correct
B) Only 2 is correct
C) Either 1 or 2
D) None of these

Answers

Answer:

The answer is "Option A".

Explanation:

Add extra functionality, otherwise, it increases the R-square value, which is defined in the following points:      

To incorporate essential elements, R-square is explicitly promoted. It Increases the R-square value, which is an additional feature. It removes the features, which provide the value of the reduce R-square. After incorporating the additional features is used as the model, which is R-square, which is never reduced.

Comprehension s best described as the ability to

Answers

Answer:

The ability to understand

Explanation:

Answer:

recognize reading strategies.

Explanation:

Write a function named power that accepts two parameters containing integer values (x and n, in that order) and recursively calculates and returns the value of x to the nth power.

Answers

Answer:

Following are the code to the given question:

int power(int x, int n)//defining a method power that accepts two integer parameters

{

if (n == 0)//defining if block to check n equal to 0

{

return 1; //return value 1

}

else//defining else block

{

x = x * power(x, --n); //use x variable to call method recursively

}

return x; //return x value

}

Explanation:

In the above-given code, a method power is defined that accepts two integer variable in its parameter, in the method a conditional statement is used which can be defined as follows:

In the if block, it checks "n" value, which is equal to 0. if the condition is true it will return value 1.In the else block, an integer variable x is defined that calls the method recursively and return x value.

Nathaniel wanted to buy a microphone. He went to an electronics store and was told that there are actually two types of microphones that he can choose from. What are the two types of microphones that Nathaniel can choose from?
Nathaniel can choose either of two types of microphone: dynamic or ____ .

Answers

Answer:

Condenser Microphone

Explanation:

google

Feel free to make me brainlyest!

Answer: condenser

Explanation:

i took the test and got it correct

A(n) ___________ analyzes traffic patterns and compares them to known patterns of malicious behavior.a. Intrusion prevention system b. intrusion detection system c. defense-in-depth strategy d. quantitative risk assessment

Answers

Answer:b. intrusion detection system

Explanation:

An intrusion detection system (IDS)  helps to  alert  service administrators   to detect suspicious or malicious activity  by monitoring and analyzing  specific patterns to network traffic. Most times, the IDS may be configured  to  respond to suspicious malicious traffic by  blocking the cyber attacker making  such IP address unable to access that particular  network.

An intrusion detection system (IDS)  can be either a Host Based Intrusion Detection Systems (HIDS) or a Network Based Intrusion Detection Systems (NIDS) depending on preference by the user.

It is therefore necessary for  businesses who require high level of security   to adopt good and effective  intrusion detection systems so  that the communication of information from businesses to businesses  can be safeguarded and secure from cyber attacks.

briefly describe what a variable is

Answers

Answer:

In mathematics, a variable is a symbol or letter, such as "x" or "y," that represents a value. In algebraic equations, the value of one variable is often dependent on the value of another. Variables are also used in computer programming to store specific values within a program

Explanation:

Warzone Players Drop Activison ID!!!

Answers

Answer:

I don't know what that is!!!

Explanation:

bc i only play rblx with two o's!!!

Answer: xXPanda_SenseiXx is my ID

Explanation:

Which of the following is a collection of data organized in a manner that allows access, retrieval, and use of that data?

Answers

Answer:

a database

Explanation:

I'm pretty sure it's database but you didn't give the multiple choice answers. hope database is one of them.

What is an online friend wants to meet up with me?

WILL MARK BRAINLIEST
This is for follow up questions for, Lesson 3: Cyber Community Unit 6: Internet Safety.

Answers

Answer:

A trafficker

Explanation:

4. When the keyword ____________________ is followed by a parenthesis, it indicates a call to the superclass constructor.

Answers

Answer:

Super

Explanation:

In object-oriented programming (OOP) language, an object class represents the superclass of every other classes when using a programming language such as Java. The superclass is more or less like a general class in an inheritance hierarchy. Thus, a subclass can inherit the variables or methods of the superclass.

Basically, all instance variables that have been used or declared in any superclass would be present in its subclass object.

Hence, when the keyword super is followed by a parenthesis, it indicates a call to the superclass constructor and it should be the first statement declared in the subclass constructor.

a) Explain 3 phase Alternative Current with aid of diagram.​

Answers

Three-phase electric power is a common method of alternating current electric power generation, transmission, and distribution. It is a type of polyphase system and is the most common method used by electrical grids worldwide to transfer power. It is also used to power large motors and other heavy loads.

A three-wire three-phase circuit is usually more economical than an equivalent two-wire single-phase circuit at the same line to ground voltage because it uses less conductor material to transmit a given amount of electrical power. Polyphase power systems were independently invented by Galileo Ferraris, Mikhail Dolivo-Dobrovolsky, Jonas Wenström, John Hopkinson and Nikola Tesla in the late 1880s.

Do you think Mortal Combat is cool?

Answers

Answer:

yes

Explanation:

Answer:

yes

Explanation:

The coding system that has just two characters is called:

a
binary
b
dual.
c
basic.
d
double.

Answers

Answer:

A. Binary

Definition:

Pertaining to a number system that has just two unique digits 0 and 1. - binary code

what do we use HTTP and HTML for?

Answers

HTTP is protocol while HTML is a language

HTML is a Language while HTTP is a Protocol.

HTML tags are used to help render web pages. The Hypertext Mark-up Language (or HTML) is the language used to create documents for the World Wide Web.

HTTP (Hypertext Transfer Protocol) is a protocol for transferring the hypertext pages from Web Server to Web Browser. HTTP is a generic and stateless protocol which can be used for other purposes as well using extensions of its request methods, error codes, and headers. Basically, HTTP is a TCP/IP based communication protocol, that is used to deliver data (HTML files, image files, query results, etc.) on the World Wide Web.

Describe an algorithm that takes as input a list of n integers in nondecreasing order and produces the list of all values that occur more than once. (

Answers

Answer:

Input a series of integer numbers and split the string from the input to get a list. Then check and convert each string to integer with a list comprehension. Create a new variable with a value equal to the set of the list ( to get unique values) then check for the occurrence of each value in the original list.

Explanation:

This algorithm is used to check for the occurrence of values in a list that has been sorted in ascending order. This is faster if the items in the list is not converted to integer yet (still strings) before writing a for loop to check the value count in the list.

what is the art of prolonging the life of the food items that are available​

Answers

Answer:

Food preservation.

Explanation:

Food preservation can be defined as an art that typically deals with the process of preventing food spoilage by reducing or mitigating the growth of microorganisms and other external factors while maintaining the nutritional value, flavor and texture of the food.

Some of the factors that causes food spoilage include microorganisms (bacteria, yeast and molds), temperature, moisture content, oxidation etc.

Hence, food preservation is the art of prolonging the life of the food items that are available.

Basically, there are physical, chemical and biological methods which can be used to prolong the life of food items and thus sustaining the edibility and nutritional value of foods. These methods are;

1. Freezing.

2. Pasteurization.

3. Drying.

4. Retorting.

5. Thermal sterilization.

6. Fermentation.

7. Irradiation.

Write (i.e. implement/define/code) a public class MakeHelloWorld that when compiled and executed prints the code for a public class HelloWorld to the standard output stream. The generated public class HelloWorld, when compiled and executed, prints to the standard output stream:

Answers

Answer:

Following are the code to this question:

public class HelloWorld //defining a class HelloWorld

{

public static void main(String[] ax)//defining maion method

{

 System.out.println("Hello, my name is D..");//print message

}

}

Output:

Hello, my name is D..

Explanation:

In the above-given java program code, a class "HelloWorld" is defined, and inside the class, the main method is declared that, and inside the main method, the print method is used, that prints a string value.

In this program, inside the main method, it uses a string type class, that helps to prints the string value.

NEED HELP ASAP
Jules is editing a short film that his production crew shot. Which TWO tools will be most important for this project?

media player
animation tool
movie editing tool
sound editing tool
gaming tool

Answers

Answer:

Movie editing and Sound Editing

Explanation:

Gaming tool will not help edit video and audio that the production crew have shot. Media player will simply just play the video and not allow them to edit it. Animation tool isn't useful unless they plan on doing SFX.

The editing of short film by Jules required him most importantly with the movie editing tool and the sound editing tool.

What is a short film?

A short film is given as the motion picture that is small and helps in the development of the presentation, direction and professional abilities.

The short film editing requires the crew to work on the media with the movie editing tool, as well as on the sound editing with changing the background sounds and adding sounds with the help of the sound editing tool.

Thus, options C and D are correct.

Learn more about short films, here:

https://brainly.com/question/10593024

#SPJ2

Q Basic program write a program in Q Basic to find the cost of 10 pens when the cost of 15 pens is 75 use unitary method to find calculate the cost of one pen calculate the print of cost of 10 pen computer answer​

Answers

give the function of cpu

Other Questions
How did the idea of Nationalism influence Latin America in the 1800s? If 500g of a material goes through four half-lives, how much material will be left? Round to two decimal places.A. 125gB. 62.5gC. 250gD. 31.25g I need help on this question 4. Sasha sells t-shirts. Each day she earns a set amount, plus acommission. Write a linear function fto determine Sasha's pay.T-shirts 1 2 3 4 5Total Pay 68 71 74 77 80 What did Revere, Dawes and Prescott do? Human cells have 46 chromosomes. Each chromosome consists of a pair of identical chromatids attached together by a structure called a centromere. Once the chromosome has split, each chromatid is called a daughter chromosome. At the end of cytokinesis, how many daughter chromosomes will be found in each cell? Explain. PPLZ HURRY WILL MAK BRAINLIEST Native American impact?? solve this question and help save my life! Sam read that all subsystems interact with each other. Which example shows how changes in the cryosphere can affect the geosphere? At the time it was written, this clause originally applied toOstate law only.O federal law only.O state and federal law.O local, state, and federal law. How are prism and cylinders are alike ? pls answer this pls im gonna die Factor completely:4a^2+8a-140 otra forma de representar 42/9 Which of these types of land is included under special land use? Please help, for AP Human Geography, I only have an hour left. :/The excerpt is the English translation of a Vietnamese folk song. While seedlings for the summer crop are not old when they are three months of age, Seedlings for the winter crop are certainly not young when they are one-and-a-half months old. Which statement best describes this folk song? a. It likely originated anonymously and was used to orally convey information about agricultural technology.b. It was likely written by a musician and sold to farmers who wanted information about agricultural technology. c. It likely originated anonymously and spread to other cultures where agriculture was important. d. It likely was written by a farmer and sold to the public for use in special music festivals. e. It likely began as a tribal story and spread to other cultures looking for agricultural technology tips. Write a slope-intercept form equation for a line thatpasses through (0,4) and (2,-2). Show the step by step process please. A detachable shirt front is called a(n):dickeyascotjabotcravat A baseball player hits a ball with a bat. At one moment the force exerted by the bat on the ball is 18,000 N. At that same moment, how much force is exerted on the bat by the ball? a) 18,000 N b) less than 18,000 N c) more than 18,000 N