HP Forums
Factoring Integer into Primes: HP 48GX - Printable Version

+- HP Forums (https://archived.hpcalc.org/museumforum)
+-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html)
+--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html)
+--- Thread: Factoring Integer into Primes: HP 48GX (/thread-144838.html)



Factoring Integer into Primes: HP 48GX - John Ferman - 12-19-2008

I have the HP41 PPC ROM which contains a routine for factoring any integer into its prime number factors. I am reverse engineering it to make it run on the HP48GX. But might someone already have done that. Anyone know?


Re: Factoring Integer into Primes: HP 48GX - Hal Bitton in Boise - 12-20-2008

Hi John,

I wrote a prime factor program for my HP67 some time ago. In addition to prime factors, it will give all the primes between two given numbers as well. I'd love to have it on my 48gx, but I'm not that adept at RPL programming. Let me know if you want me to post it.

Best regards, Hal


Re: Factoring Integer into Primes: HP 48GX - John Mosand - 12-20-2008

My HP 48SX came with a factoring prg 'built in', among several other prgs in VAR. It factors a 10 digit number in less than half a sec. It shows automatically how long time it takes.


Re: Factoring Integer into Primes: HP 48GX - Gerson W. Barbosa - 12-20-2008

Quote:
I am reverse engineering it to make it run on the HP48GX.

Joe Horn has done this already:

123456789 RT -> 123456789: { 3 3 3607 3803 } 25.82 seconds (HP-48GX)
5961027250 RT -> 5961027250: { 2 5 5 5 3011 7919} 21.95 seconds
%%HP: T(3)A(D)F(,);
DIR
pf
\<< DUP { } SWAP
DO NP ROT
OVER + ROT ROT /
DUP
UNTIL 1 ==
END DROP SWAP
\->TAG
\>>
NP
\<< DUP \v/ \-> s
\<< DUP
IF 2 MOD
THEN 3
WHILE
DUP2 MOD OVER s <
AND
REPEAT 2
+
END DUP s
IF >
THEN DROP
DUP
END
ELSE 2
END
\>>
\>>
RT
\<< TIME SWAP pf
TIME ROT HMS- HMS\->
3600 * SWAP
\>>
END

I've written a List-to-Algebraic routine that will change { 3 3 3607 3803 } to '3^2*3607*3803'.

Gerson.


Re: Factoring Integer into Primes: HP 48GX - Hal Bitton in Boise - 12-20-2008

Thank you Gerson,

I'll key this into my 48gx and try it out.

Best regards, hal


Re: Factoring Integer into Primes: HP 48GX...help with the RPL syntax - Hal Bitton in Boise - 12-20-2008

I'm trying to key in and run this program, which Gerson Barbosa was kind enough to post, and have a couple of questions.

1. What are all the backslashes? I can't find that character listed in the 48G manual. I'm assuming the forward slashes denote division.

2. Could someone help me decipher this line " \<< DUP \v/ \-> s", in particular the backslashes, and the \v/?


My apologies for not being more RPL savvy, but I think I'm not alone in this boat:)

Best regards, hal


Re: Factoring Integer into Primes: HP 48GX...help with the RPL syntax - V-PN - 12-21-2008

When you transfer special calculator characters they get automatically replaced by trigraphs (and back)


trigraphs


Edited: 21 Dec 2008, 1:15 a.m.


Re: Factoring Integer into Primes: HP 48GX...help with the RPL syntax - Hal Bitton in Boise - 12-21-2008

Thank you V-PN,

I see the light!! The program works beautifully now.



best regards, hal




Re: Factoring Integer into Primes: HP 48GX...help with the RPL syntax - Gerson W. Barbosa - 12-22-2008

V-PN has already been of help. Anyway, this is Joe Horn's program and documentation:

http://www.hpcalc.org/hp48/math/misc/prime.zip

I've just found my L2A (list to algebraic) program, which I thought resided only in my HP-28S memory, here:

http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/archv018.cgi?read=138380 (Message #8)

An even faster program is presented by Joe Horn himself in message #9, which I hadn't read yet. Thanks, Joe!

Regards,

Gerson.