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 K 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 Like