All Questions

53
votes
12answers
112401 views

How to find GCD, LCM on a set of numbers

What would be the easiest way to calculate Greatest Common Divisor and Least Common Multiple on a set of numbers? What math functions can be used to find this information?
11
votes
5answers
27475 views

Euclidean algorithm (GCD) with multiple numbers?

So I'm writing a program in Python to get the GCD of any amount of numbers. def GCD(numbers): if numbers[-1] == 0: return numbers[0] # i'm stuck here, this is wrong for i in ra...
27
votes
13answers
35186 views

what is the fastest way to find the gcd of n numbers?

what is the fastest way to compute the greatest common divisor of n numbers?
63
votes
15answers
144643 views

Java: get greatest common divisor

I have seen that such a function exists for BigInteger, i.e. BigInteger#gcd. Are there other functions in Java which also works for other types (int, long or Integer)? It seems this would make sense a...
10
votes
5answers
8300 views

How does the Euclidean Algorithm work?

I just found this algorithm to compute the greatest common divisor in my lecture notes: public static int gcd( int a, int b ) { while (b != 0) { final int r = a % b; a = b; ...
39
votes
8answers
6671 views

"Approximate" greatest common divisor

Suppose you have a list of floating point numbers that are approximately multiples of a common quantity, for example 2.468, 3.700, 6.1699 which are approximately all multiples of 1.234. How would y...
19
votes
6answers
51849 views

GCD function in c++ sans cmath library

I'm writing a mixed numeral class and need a quick and easy 'greatest common divisor' function. Can anyone give me the code or a link to the code?
14
votes
6answers
11062 views

Euclidean greatest common divisor for more than two numbers

Can someone give an example for finding greatest common divisor algorithm for more than two numbers? I believe programming language doesn't matter.
8
votes
4answers
8313 views

Numpy gcd function

Does numpy have a gcd function somewhere in its structure of modules? I'm aware of fractions.gcd but thought a numpy equivalent maybe potentially quicker and work better with numpy datatypes. I have...
23
votes
3answers
26731 views

JS how to find the greatest common divisor

I would like to find the greatest common divisor using JavaScript. Anyone done that before and willing to share?

Previous Next