Python Program for Basic Euclidean algorithms Last Updated : 22 Jun, 2022 Comments Improve Suggest changes Like Article Like Report Python3 # Python program to demonstrate Basic Euclidean Algorithm # Function to return gcd of a and b def gcd(a, b): if a == 0 : return b return gcd(b%a, a) a = 10 b = 15 print("gcd(", a , "," , b, ") = ", gcd(a, b)) a = 35 b = 10 print("gcd(", a , "," , b, ") = ", gcd(a, b)) a = 31 b = 2 print("gcd(", a , "," , b, ") = ", gcd(a, b)) # Code Contributed By Mohit Gupta_OMG <(0_o)> Output: GCD(10, 15) = 5 GCD(35, 10) = 5 GCD(31, 2) = 1 Time Complexity: O(Log min(a, b)) Auxiliary Space: O(Log min(a, b)), due to recursion stack. Please refer complete article on Basic and Extended Euclidean algorithms for more details! Comment More infoAdvertise with us Next Article Python Program for Basic Euclidean algorithms kartik Follow Improve Article Tags : Python Practice Tags : python Similar Reads Python Program for Extended Euclidean algorithms Python3 # Python program to demonstrate working of extended # Euclidean Algorithm # function for extended Euclidean Algorithm def gcdExtended(a, b): # Base Case if a == 0 : return b,0,1 gcd,x1,y1 = gcdExtended(b%a, a) # Update x and y using results of recursive # call x = y1 - (b//a) * x1 y = x1 ret 1 min read Python Arithmetic Operators Python operators are fundamental for performing mathematical calculations. Arithmetic operators are symbols used to perform mathematical operations on numerical values. Arithmetic operators include addition (+), subtraction (-), multiplication (*), division (/), and modulus (%). OperatorDescriptionS 4 min read Python Program for GCD of more than two (or array) numbers The GCD of three or more numbers equals the product of the prime factors common to all the numbers, but it can also be calculated by repeatedly taking the GCDs of pairs of numbers. gcd(a, b, c) = gcd(a, gcd(b, c)) = gcd(gcd(a, b), c) = gcd(gcd(a, c), b) Python # GCD of more than two (or array) numbe 1 min read Calculate Euclidean Distance Using Python OSMnx Distance Module Euclidean space is defined as the line segment length between two points. The distance can be calculated using the coordinate points and the Pythagoras theorem. In this article, we will see how to calculate Euclidean distances between Points Using the OSMnx distance module. Syntax of osmnx.distance. 4 min read Python Program for Find minimum sum of factors of number Given a number, find minimum sum of its factors.Examples: Input : 12Output : 7Explanation: Following are different ways to factorize 12 andsum of factors in different ways.12 = 12 * 1 = 12 + 1 = 1312 = 2 * 6 = 2 + 6 = 812 = 3 * 4 = 3 + 4 = 712 = 2 * 2 * 3 = 2 + 2 + 3 = 7Therefore minimum sum is 7Inp 1 min read Python program for multiplication and division of complex number Given two complex numbers. The task is to multiply and divide them. Multiplication of complex number: In Python complex numbers can be multiplied using * operator Examples: Input: 2+3i, 4+5i Output: Multiplication is : (-7+22j) Input: 2+3i, 1+2i Output: Multiplication is : (-4+7j) Python3 # Python p 3 min read Assignment Operators in Python The Python Operators are used to perform operations on values and variables. These are the special symbols that carry out arithmetic, logical, and bitwise computations. The value the operator operates on is known as the Operand. Assignment Operators are used to assign values to variables. This opera 7 min read Calculate the Euclidean distance using NumPy Euclidean distance is the shortest between the 2 points irrespective of the dimensions. In this article to find the Euclidean distance, we will use the NumPy library. This library used for manipulating multidimensional array in a very efficient way. Let's discuss a few ways to find Euclidean distanc 2 min read Python Multi-Maths Package The Multi-Maths Python library is a powerful tool that combines arithmetic, geometry, and statistics functions into a single package. This library allows data scientists and analysts to perform a wide range of mathematical operations without the need for multiple specialized libraries.In this articl 6 min read Python Program for Common Divisors of Two Numbers Given two integer numbers, the task is to find the count of all common divisors of given numbers? Input : a = 12, b = 24Output: 6Explanation: all common divisors are 1, 2, 3, 4, 6 and 12Input : a = 3, b = 17Output: 1Explanation: all common divisors are 1Input : a = 20, b = 36Output: 3Explanation: al 1 min read Like