answersLogoWhite

0


Best Answer

To calculate the least common multiple (lcm) of decimals (integers) and fractions you first need to calculate the greatest common divisor (gcd) of two integers:

int gcd (int a, int b) {

int c;

while (a != 0) {

c = a;

a = b % a;

b = c;

}

return b;

}

With this function in place, we can calculate the lcm of two integers:

int lcm (int a, int b) {

return a / gcd (a, b) * b;

}

And with this function in place we can calculate the lcm of two fractions (a/b and c/d):

int lcm_fraction (int a, int b, int c, int d) {

return lcm (a, c) / gcd (b, d);

}

User Avatar

Wiki User

7y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the least common multiple of decimals and fractions in C?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you find the least common multiple in python program?

I suggest you use the property that lcm(a, b) * gcf(a, b) = a * b. Solving for the least common multiple: lcm(a, b) = a * b / gcf(a, b). The greatest common factor can be obtained with Euclid's algorithm. For example, the gcf of 14 and 10 is the same as the gcf of 10 and 4, where 4 is the remainder of dividing 14 by 10. In most programming languages, this remainder is calculated with the percent sign: 14 % 10, or rather, a % b. Repeat until you get a zero remainder.


What is the least common goal of an entrepreneur?

bankruptcy


Write a program to find the L.C.M. and HCF of two number using function where numbers are passed as parameter use function with return value?

For the greatest common factor, you can use the following to your advantage. As an example, take the numbers 14 and 10 as input.The greatest common factor of 14 and 10 is the same as the greatest common factor of 10 and 4, where 4 has been obtained by subtracting 14 - 10 (or, faster, to avoid repeated subtraction, take the remainder of a division: 14 % 10).If you divide 10 % 4 (or subtract 4 twice, from 10), you get a remainder of 2, so the new set of numbers is 4 and 2.Next step: 4 % 2 = 0. Once you get a remainder of zero, the previous number is the answer - the number that you should return. In this case, the 2.For the least common multiple, use the property that (using a numeric example) 14 x 10 = 2 x 70 (14 and 10 are the two parameters, 2 and 70 are the greatest common factor and the least common multiple, respectively).For the greatest common factor, you can use the following to your advantage. As an example, take the numbers 14 and 10 as input.The greatest common factor of 14 and 10 is the same as the greatest common factor of 10 and 4, where 4 has been obtained by subtracting 14 - 10 (or, faster, to avoid repeated subtraction, take the remainder of a division: 14 % 10).If you divide 10 % 4 (or subtract 4 twice, from 10), you get a remainder of 2, so the new set of numbers is 4 and 2.Next step: 4 % 2 = 0. Once you get a remainder of zero, the previous number is the answer - the number that you should return. In this case, the 2.For the least common multiple, use the property that (using a numeric example) 14 x 10 = 2 x 70 (14 and 10 are the two parameters, 2 and 70 are the greatest common factor and the least common multiple, respectively).For the greatest common factor, you can use the following to your advantage. As an example, take the numbers 14 and 10 as input.The greatest common factor of 14 and 10 is the same as the greatest common factor of 10 and 4, where 4 has been obtained by subtracting 14 - 10 (or, faster, to avoid repeated subtraction, take the remainder of a division: 14 % 10).If you divide 10 % 4 (or subtract 4 twice, from 10), you get a remainder of 2, so the new set of numbers is 4 and 2.Next step: 4 % 2 = 0. Once you get a remainder of zero, the previous number is the answer - the number that you should return. In this case, the 2.For the least common multiple, use the property that (using a numeric example) 14 x 10 = 2 x 70 (14 and 10 are the two parameters, 2 and 70 are the greatest common factor and the least common multiple, respectively).For the greatest common factor, you can use the following to your advantage. As an example, take the numbers 14 and 10 as input.The greatest common factor of 14 and 10 is the same as the greatest common factor of 10 and 4, where 4 has been obtained by subtracting 14 - 10 (or, faster, to avoid repeated subtraction, take the remainder of a division: 14 % 10).If you divide 10 % 4 (or subtract 4 twice, from 10), you get a remainder of 2, so the new set of numbers is 4 and 2.Next step: 4 % 2 = 0. Once you get a remainder of zero, the previous number is the answer - the number that you should return. In this case, the 2.For the least common multiple, use the property that (using a numeric example) 14 x 10 = 2 x 70 (14 and 10 are the two parameters, 2 and 70 are the greatest common factor and the least common multiple, respectively).


What is micro meter least count?

Generally least count of micrometer varies instrument to instrument.. But common micrometers which are used in institute level laboratories have least count of 0.0001mm


Flow chart of LCM?

See the related links posted below. It is a good example of calculating the Least Common Multiplier.

Related questions

What is the least common denominator of two fractions?

The least common denominator is the least common multiple of the denominators of the fractions.


A common multiple of the denominators of two or more fractions?

the common denominator!


What is the least common multiple of the denominator of two or more fractions is their?

least common denominator


What is a sentence for least common multiple?

The least common multiple of 6 and 9 is 18.


IS THE LEAST COMMON mULTIPLE OF THE DENOMINATORS OF TWO OR MORE FRACTIONS?

The least common denominator, or LCD


What Is least common multiple of the denominators of two or more fractions?

That's the least common denominator.


What is the least common multiple of the denominators of the fractions?

That's known as the least common denominator, or LCD.


What is the name of a least common multiple of the denominators of two more fractions?

The least common denominator.


What is the LCD for fractions?

The LCD for fractions is the LCM (least common multiple) of all of the denominators.


What is the least common multiple of 2.2 and 5?

The Least Common Multiple (LCM) for 22 5 is 110.


Do you use the Least Common Multiple when subtracting fractions?

Yes.


What is the blank is the least common multiple of the denominators of the fractions?

It is the LCD.