Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Such a Simple Problem...???

84 views
Skip to first unread message

TranslucentAmoebae

unread,
May 12, 2005, 6:51:25 PM5/12/05
to
i've been trying to come up with a program that takes a list of whole
numbers & returns their Lowerest Common Factor...!
so that { 6 9 } -> 18
or { 2 6 8 12 } -> 24
it seems so simple... and yet...
it's baffling me...???
what's the elegant solution to this...???

Virgil

unread,
May 12, 2005, 7:08:37 PM5/12/05
to
In article <1115938285.7...@o13g2000cwo.googlegroups.com>,
"TranslucentAmoebae" <transa...@seanet.com> wrote:

You seem to be wanting the least common multiple, not a "lowerest [sic]
common factor".

In which case,

\<< \<< LCM \>> STREAM \>>

is about as good as you are likely to get.

LCM finds the least common multiple of two numbers, and STREAM makes it
work on a list.

Werner

unread,
May 13, 2005, 3:27:50 AM5/13/05
to
\<< ::LCM DTAG STREAM \>>
Cheers, Werner

Lance

unread,
May 13, 2005, 7:18:56 AM5/13/05
to

--------

I think the other replies have shown how to DO this using the HP calc.
But I find myself wondering whether you were really after the algorithm
by which the problem is solved?

Lance

TranslucentAmoebae

unread,
May 13, 2005, 8:37:33 PM5/13/05
to

thanx for considering this...
because i have an ancient ( the old good kind ) HP48gx,
and it doesn't have the built in ( ? ) function LCM or STREAM...!
What is the logic/thinking behind these functions...???
thanx!

Virgil

unread,
May 13, 2005, 9:24:35 PM5/13/05
to
In article <1116031053....@o13g2000cwo.googlegroups.com>,
"TranslucentAmoebae" <transa...@seanet.com> wrote:

For a GCF (greatest common factor) program, you can use
\<< WHILE DUP REPEAT SWAP OVER MOD END DROP ABS \>>
though IIRC, there is a built in hp48g command, GCD, which does the same
thing.

For a LCM (least common multiple) program use
\<< DUP2 * ROT ROT GCD / \>>
or substitute the above GCF program for the GCD in this program.

Then for LCM of a list ( of at least 2 numbers) use

\<< LIST\-> 2 OVER START LCM NEXT \>>

Werner

unread,
May 18, 2005, 2:15:09 AM5/18/05
to
GCD: \<< WHILE SWAP DUP2 REPEAT MOD END DROP2 ABS \>>
LCM: \<< DUP2 GCD / * \>>
LLCM: \<< LIST\-> 2 SWAP START LCM NEXT \>> (yours had an error)

The 48 does not contain a GCD command, the 49 does. well except for the
48GII, which is really a 49 in disguise.

Cheers, Werner

John H Meyers

unread,
May 23, 2005, 10:43:56 PM5/23/05
to
On Fri, 13 May 2005 19:37:33 -0500, TranslucentAmoebae wrote:

> I have an ancient (the old good kind) HP48gx,


> and it doesn't have the built in (?) function LCM or STREAM...!

The HP48G[X] has STREAM (a list processing command),
but neither GCD nor LCM.

Here are some old GCD programs for HP48, plus an interesting challenge:

http://groups-beta.google.com/group/comp.sys.hp48/browse_frm/thread/73f62fcaa63ecac1/24dada9d08c0f265#24dada9d08c0f265

(note that Werner Huysegoms usually produces the best programs :)

For LCM you can use DUP2 GCD / * [as Werner also said]

How about for fractions?
http://groups-beta.google.com/group/comp.sys.hp48/browse_frm/thread/b970d3d39628af5b/795fc1a4f89e2433#795fc1a4f89e2433

[r->] [OFF]

0 new messages