how can find lcm of fraction number.
조회 수: 140 (최근 30일)
이전 댓글 표시
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
Dyuman Joshi
2023년 4월 17일
Hint - There is a method to obtain LCM of fractional numbers. Search on the internet.
답변 (1개)
Aman
2023년 6월 2일
Hi there,
Here are the steps to find LCM of fractions a/b and c/d:
- Find the LCM of b and d = LCM(b,d)
- Multiply the numerator and denominator of both the fractions by LCM(b,d), After this multiplication, denominator of both fractions are same.
- 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!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!