All Questions

127
votes
27answers
122891 views

Least common multiple for 3 or more numbers

How do you calculate the least common multiple of multiple numbers? So far I've only been able to calculate it between two numbers. But have no idea how to expand it to calculate 3 or more numbers. ...
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?
18
votes
13answers
22564 views

Finding the LCM of a range of numbers

I read an interesting DailyWTF post today, "Out of All The Possible Answers..." and it interested me enough to dig up the original forum post where it was submitted. This got me thinking how I would s...
2
votes
2answers
3789 views

LCM of n numbers modulo 1000000007

I have to find LCM of n numbers MODULO 10^9+7.My approach is find LCM of two numbers and then MOD them.Then take the LCM of next element and the answer obtained from the previous iteration and MOD the...
1
votes
3answers
4358 views

Calculate LCM of N numbers modulo 1000000007

I was solving following problem on LCM : Calculate LCM of N numbers modulo 1000000007 My approach : typedef unsigned long long ull; const ull mod=1000000007; ull A[10009]; /*Euclidean GCD*/ ull gcd(...
4
votes
2answers
6283 views

GCD and LCM relation

The following relation works only for two (3, 12) numbers, it fails to produce the right answer when used for three numbers (3,12,10) . Just wondering if is it my understanding or it is just for two n...
2
votes
1answers
8444 views

LCM of all the numbers in an array in Java

I have an array of ints, and I'm trying to find the LCM (least common multiple) of all the values in the array. I've written an lcm method separately; it takes two values as input, and returns the lcm...
5
votes
4answers
1054 views

How to calculate Least common multiple of {1, 2, 3, .........., n}?

How to find LCM of {1, 2, ..., n} where 0 < n < 10001 in fastest possible way. The one way is to calculate n! / gcd (1,2,.....,n) but this can be slow as number of testcases are t < 501 and t...
1
votes
1answers
182 views

Algorithm - GCD and LCM problems

Input for this problem is an array A of positive integers and single positive integer k. The output of the program is True if k is in the set S defined below, False otherwise. Define the set S as fol...
2
votes
2answers
327 views

Lowest Common Multiple with doubles in C

I am doing an assignment for a Coursera class that asks me to calculate the Lowest Common Multiple of two numbers, either of which are no larger than 2 * 10 ^ 9. I'm writing this in C and I'm running...

Previous Next