The Museum of HP Calculators

HP Forum Archive 18

[ Return to Index | Top of Index ]

Factoring Integer into Primes: HP 48GX
Message #1 Posted by John Ferman on 19 Dec 2008, 9:54 p.m.

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
Message #2 Posted by Hal Bitton in Boise on 20 Dec 2008, 12:05 a.m.,
in response to message #1 by John Ferman

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
Message #3 Posted by John Mosand on 20 Dec 2008, 11:27 a.m.,
in response to message #2 by Hal Bitton in Boise

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
Message #4 Posted by Gerson W. Barbosa on 20 Dec 2008, 2:32 p.m.,
in response to message #1 by John Ferman

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
Message #5 Posted by Hal Bitton in Boise on 20 Dec 2008, 3:11 p.m.,
in response to message #4 by Gerson W. Barbosa

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
Message #6 Posted by Hal Bitton in Boise on 20 Dec 2008, 11:59 p.m.,
in response to message #4 by Gerson W. Barbosa

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
Message #7 Posted by V-PN on 21 Dec 2008, 1:12 a.m.,
in response to message #6 by Hal Bitton in Boise

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
Message #8 Posted by Hal Bitton in Boise on 21 Dec 2008, 9:48 a.m.,
in response to message #7 by V-PN

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
Message #9 Posted by Gerson W. Barbosa on 22 Dec 2008, 7:32 a.m.,
in response to message #6 by Hal Bitton in Boise

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.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall