Question

In: Computer Science

IN PYTHON : Write one program that will compute both the Least Common Multiple, and the...

IN PYTHON :

Write one program that will compute both the Least Common Multiple, and the Greatest Common Factor of two numbers inputted by a user.

The program will display all factors and multiples of the two numbers.  

When displaying the multiples of the numbers, only display up to the first input times the second input. \

Use functions to computer the answers.  

Loop the program so that the user can enter two new numbers after each try.

Solutions

Expert Solution

Code for copying

t=int(input("How many times you want to check : "))
m=0
while m<t:
    print("case {}".format(m+1))
    n1=int(input("Enter first number : "))
    n2=int(input("Entersecond number : "))
    list1=[]
    list2=[]
    list3=[]
    for i in range(1,n1+1):
        if n1%i==0:
            list1.append(i)
    for i in range(1,n2+1):
        if n2%i==0:
            list2.append(i)
    for i in range(1,n1+1):
        list3.append(n2*i)
    def p1(n1,n2):
        while(n2):
            n1, n2 = n2, n1 % n2
        return n1
    def p2(n1,n2):
        return (n1*n2)/p1(n1,n2)
  
    print("Gcd is {} ".format(p1(n1,n2)))  
    print("LCM is {} ".format(p2(n1,n2)))  
    print("factors of {} = {} ".format(n1,list1))
    print("factors of {} = {} ".format(n2,list2))
    print("multiples of {} = {} ".format(n2,list3))
    m+=1


Related Solutions

Write a C++ program to find least common multiple (LCM) of two, three and four integer...
Write a C++ program to find least common multiple (LCM) of two, three and four integer values. The integer values are entered from the keyboard and the outputs are printed to the console. The LCM of two, three and four integer values are computed using Prime factorization method. You have to use arrays to hold input values and use functions/methods to get data from the keyboard, display output to the console, calculate LCM using Prime factorization method. Your program should...
Write a C++ program to find least common multiple (LCM) of two, three and four integer...
Write a C++ program to find least common multiple (LCM) of two, three and four integer values. The integer values are entered from the keyboard and the outputs are printed to the console. The LCM of two, three and four integer values are computed using Prime factorization method. You have to use arrays to hold input values and use functions/methods to get data from the keyboard, display output to the console, calculate LCM using Prime factorization method. Your program should...
Write a Python program that: Create the algorithm in both flowchart and pseudocode forms for the...
Write a Python program that: Create the algorithm in both flowchart and pseudocode forms for the following requirements: Reads in a series of positive integers,  one number at a time;  and Calculate the product (multiplication) of all the integers less than 25,  and Calculate the sum (addition) of all the integers greater than or equal to 25. Use 0 as a sentinel value, which stops the input loop. [ If the input is 0 that means the end of the input list. ]...
Write a program IN PYTHON of the JUPYTER NOOTBOOK Write a Python program that gets a...
Write a program IN PYTHON of the JUPYTER NOOTBOOK Write a Python program that gets a numeric grade (on a scale of 0-100) from the user and convert it to a letter grade based on the following table. A: 90% - 100% B 80% - 89% C 70% - 79% D 60% - 69% F <60% The program should be written so that if the user entered either a non-numeric input or a numeric input out of the 0-100 range,...
Write a Python program to count occurrences of items (and retrieve the most 3 or least...
Write a Python program to count occurrences of items (and retrieve the most 3 or least 3 words). Write a Python program to sort a dictionary by keys or values in ascending or descending order by 2 methods.
Write a Python program that simulates a restaurant ordering system where it stores multiple orders of...
Write a Python program that simulates a restaurant ordering system where it stores multiple orders of a dish and the price for each order stored into a list. The program will then print the receipt which includes list of orders and their price along with the subtotal before tax, the tax amount, and the final total. Also include tip suggestions for 10%, 15% and 20%. Use the format specifiers to make the price line up and the tip only 2...
Program must be in Python Write a program in Python whose inputs are three integers, and...
Program must be in Python Write a program in Python whose inputs are three integers, and whose output is the smallest of the three values. Input is 7 15 3
Calculating Delivery Cost Program in Python write a program in Python that will ask a user...
Calculating Delivery Cost Program in Python write a program in Python that will ask a user to enter the purchase total, the number of the items that need to be delivered and delivery day. Then the system displays the cost of delivery along with the total cost. Purchase total > $150 Yes Number of the items (N) N<=5 N>=6 Delivery day Same Day Next Day Same Day Next Day Delivery charges ($) 8 N * 1.50 N * 2.50 N...
Write a python program. Grades are values between zero and 10 (both zero and 10 included),...
Write a python program. Grades are values between zero and 10 (both zero and 10 included), and are always rounded to the nearest half point. To translate grades to the American style, 8.5 to 10 become an “A,” 7.5 and 8 become a “B,” 6.5 and 7 become a “C,” 5.5 and 6 become a “D,” and other grades become an “F.” Implement this translation, whereby you ask the user for a grade, and then give the American translation. If...
Circle Object Python program Compute the area and perimeter of a circle using Python classes. take...
Circle Object Python program Compute the area and perimeter of a circle using Python classes. take the radius from the user and find the area and perimeter of a circle please use comments to explain so i better understand
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT