HP Forums
find the lowest common denominator - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: find the lowest common denominator (/thread-9938.html)



find the lowest common denominator - Hamada-77 - 01-15-2018 10:25 AM

hello
how can i find the lowest common denominator of two numbers with Hp prime ?
thanks


RE: find the lowest common denominator - Didier Lachieze - 01-15-2018 12:53 PM

I'm not sure there is a build-in function providing the lowest common denominator.
So here is a small program doing that:

Code:
EXPORT LCD(N,M)
BEGIN
 LOCAL l:={};
 l:=INTERSECT(mat2list(idivis(N)),mat2list(idivis(M)));
 RETURN l(MIN(SIZE(l),2));
END;



RE: find the lowest common denominator - Joe Horn - 01-15-2018 12:59 PM

(01-15-2018 12:53 PM)Didier Lachieze Wrote:  I'm not sure there is a build-in function providing the lowest common denominator.

There is: it's the lcm function (lowest common multiple). In CAS, it works on integers of any length.

lcm(12,18) --> 36
1/12+1/18 --> 5/36

It also works on polynomials, not just integers.


RE: find the lowest common denominator - Didier Lachieze - 01-15-2018 01:20 PM

Good point, I misunderstood the request as beeing for the lowest common divisor.


RE: find the lowest common denominator - john gustaf stebbins - 01-16-2018 12:31 AM

I'm getting to go through this basic math with my kids now.

I think the least common divisor can be found with the "1" function.

;^)

On the 50g, this was actually function of sort, at least a token so that this commonly used number parsed faster than a number literal. Don't know that they have done the same with the Prime.

-jgs