Effacer les filtres
Effacer les filtres

how can find lcm of fraction number.

37 vues (au cours des 30 derniers jours)
se chss
se chss le 17 Avr 2023
Réponse apportée : Aman le 2 Juin 2023
a = 3/10, b = 4/7
how can i find lcm of a and b?
matlab fucntion lcm input must be integer, so i cannot use lcm function.
  1 commentaire
Dyuman Joshi
Dyuman Joshi le 17 Avr 2023
Hint - There is a method to obtain LCM of fractional numbers. Search on the internet.

Connectez-vous pour commenter.

Réponses (1)

Aman
Aman le 2 Juin 2023
Hi there,
Here are the steps to find LCM of fractions a/b and c/d:
  1. Find the LCM of b and d = LCM(b,d)
  2. Multiply the numerator and denominator of both the fractions by LCM(b,d), After this multiplication, denominator of both fractions are same.
  3. Find LCM of the new numerators and the answer is LCM(new numerators)/LCM(b,d).
Here is the MATLAB implementation of the above algorithm:
a = 3/10;
b = 4/7;
[na, da] = rat(a);
[nb, db] = rat(b);
d_lcm = (da * db) / gcd(da, db);
an = na * d_lcm / da;
bn = nb * d_lcm / db;
num_lcm = an*bn / gcd(an,bn);
lcm_result = num_lcm/d_lcm;
Hope this helps!

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by