Question

please help with python

EDIT: hmwk3q3 is just what the file is supposed to be named


Greatest Common Divisor Two integers A and B have the greatest common divisor which is the largest positive integer that divi

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Was this answer helpful? bo mo Debjit answered this 1,179 answers SOURCE CODE IN PYTHON: #input A Arint(input(Enter first nu

Add a comment
Answer #2
def gcd(x, y):    while y != 0:
        (x, y) = (y, x % y)    return x


answered by: Shivani Sharma
Add a comment
Know the answer?
Add Answer to:
please help with python EDIT: hmwk3q3 is just what the file is supposed to be named...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PYTHON In mathematics, the Greatest Common Divisor (GCD) of two integers is the largest positive integer...

    PYTHON In mathematics, the Greatest Common Divisor (GCD) of two integers is the largest positive integer that divides the two numbers without a remainder. For example, the GCD of 8 and 12 is 4. Steps to calculate the GCD of two positive integers a,b using the Binary method is given below: Input: a, b integers If a<=0 or b<=0, then Return 0 Else, d = 0 while a and b are both even do a = a/2 b = b/2...

  • C++ I do not understand this problem. 14THE GREATEST COMMON DENOMINATOR PROBLEM Write a function named...

    C++ I do not understand this problem. 14THE GREATEST COMMON DENOMINATOR PROBLEM Write a function named god() that accepts two integers as input parameters and returns the greatest common divisor of the two numbers. The greatest common divisor (GCD) of two integers, a and b, is the largest integer that is a factor of both a and b. The GCD of any number and 1 is 1, and the GCD of any number and o is that number. One efficient...

  • please help with python Write a well-documented, Python program, hmwk305.py that implements the Selection-Sort algorithm. Selection...

    please help with python Write a well-documented, Python program, hmwk305.py that implements the Selection-Sort algorithm. Selection Sort segments the list into sorted and unsorted elements. The algorithm continues to remove the smallest element of the unsorted list and adds it to the sorted segment. Implement the algorithm that accepts an unsorted list and returns a sorted one - in ascending order. 5 3 8 4 6 Initial List Minimum Swaps Position: Sorted List Length 1 Minimum Swaps Position: Sorted List...

  • Spring 2020 CSCI 2450: HW5 (Programming Assignment (10 points) Answer any ONE of the following problems....

    Spring 2020 CSCI 2450: HW5 (Programming Assignment (10 points) Answer any ONE of the following problems. If you answer both of them, you will get bonus points. Use any instructions and Irvine procedures we covered till now. These problems might require instructions from chapter 07. Problem 1: Greatest Common Divisor ( GCD) Greatest Common Divisor (GCD): The greatest common divisor (GCD) of two integers is the largest integer that will evenly divide both integers. The GCD algorithm involves integer division...

  • C++ PROGRAM ONLY! For this lab you need to write a program that will read in...

    C++ PROGRAM ONLY! For this lab you need to write a program that will read in two values from a user and output the greatest common divisor (using a recursive implementation of the Euclidean algorithm) to a file. In Lab #3, you implemented this program using an iterative method. Greatest Common Divisor In mathematics, the greatest common divisor (GCD) of two or more integers (when at least one of of them is zero then the larger value is the GCD....

  • In Assembly Language Please display results and write assembler code in (gcd.s) The Euclidean algorithm is...

    In Assembly Language Please display results and write assembler code in (gcd.s) The Euclidean algorithm is a way to find the greatest common divisor of two positive integers, a and b. First let me show the computations for a=210 and b=45. Divide 210 by 45, and get the result 4 with remainder 30, so 210=4·45+30. Divide 45 by 30, and get the result 1 with remainder 15, so 45=1·30+15. Divide 30 by 15, and get the result 2 with remainder...

  • Use R language to program Problem 1: Greatest Common Divisor (GCD) Please write two functions, g...

    Use R language to program Problem 1: Greatest Common Divisor (GCD) Please write two functions, g edi ) and gcdr , which both take two integers a, b and calculates their greatest common divisor (GCD) using the Euclidean algorithm gcdi () should do so using iteration while gcdr () should use recursion. Then write a third function, gcd(), which takes two integers a, band an optional third argument nethod which takes a charater string containing either "iterative" or "recursive", with...

  • Question 5 (10 Points) Write a well-documented, Python program, hmwk305.py that implements the Selection-Sort algorithm. Selection-Sort...

    Question 5 (10 Points) Write a well-documented, Python program, hmwk305.py that implements the Selection-Sort algorithm. Selection-Sort segments the list into sorted and unsorted elements. The algorithm continues to remove the smallest element of the unsorted list and adds it to the sorted segment. Implement the algorithm that accepts an unsorted list and returns a sorted one - in ascending order. 5 3 8 Initial List 4 6 18 4 6 Minimum Swaps Position: Sorted List Length 1 Minimum Swaps Position:...

  • Help needed related python ! Thanx 6. What makes the exclusive-or the most interesting of the...

    Help needed related python ! Thanx 6. What makes the exclusive-or the most interesting of the logic operations in Boolean algebra? (Hint: try them and see.) 7. The How Computers Work Part III video from Week 1 talks about assembly level abstraction. Why is it better than machine code? Why is the assembly level abstraction still not abstract enough? Give the 2300 year old algorithm by Euclid for finding the greatest common divisor which is: 8. 9. Get two positive...

  • YOU MUST NOT MAKE ANY CHANGES TO THAT CODE package edu.buffalo.cse116; /** * Class that can...

    YOU MUST NOT MAKE ANY CHANGES TO THAT CODE package edu.buffalo.cse116; /** * Class that can be used to test if two integers are coprime. Numbers are considered coprime iff the largest divisor * shared by both numbers is 1. Identifying coprime (also called relatively prime) numbers is valuable for RSA public * key cryptography (and possibly other things, but the author has never seen any other uses). */ public class CoprimeNumbers { /** * Given two integers, this returns...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT