Posts: 28
Threads: 3
Joined: Dec 2005
Hello all,
I always get a ton of good information and programs from the forums. Anyway, here's a present of dubious(?) value to everyone. This is what happens when you have too much time on your hands during the holidays! :) Please check it out:
Check to see if the number you have entered is prime. Program gives a result of "1" if prime, or "0" if not. If the number is not prime, hitting RCL 3 will give you the square root if the number has one, or will give you the lowest factor of the number. It isn't optimized or anything, just plain jane. The original number can be recalled by hitting RCL 1.
Legend:
/ = divide
SQRT = The square root
00-
01- STO 1
02- SQRT
03- STO 3
04- FRAC
05- X=0
06- GTO 33
07- RCL 1
08- 2
09- STO 3
10- /
11- FRAC
12- X=0
13- GTO 33
14- 3
15- STO 3
16- RCL 1
17- SQRT
18- INTG
19- STO 2
20- RCL 1
21- RCL 3
22- /
23- FRAC
24- X=0
25- GTO 33
26- RCL 3
27- RCL 2
28- X<=Y
29- GTO 36
30- 2
31- STO +3
32- GTO 20
33- 0
34- ENTER
35- GTO 00
36- 1
37- ENTER
38- GTO 00
Enter positive integers only. Enjoy!
Tony, AB9IO
Posts: 4,027
Threads: 172
Joined: Aug 2005
Hi, Anthony;
First, congratulations for your program. Looks like being an efficient code (did not run it yet, sorry...).
BTW, to which calculator has it been written? First I thought it was for the HP12C, then it came to my mind it might also fit in the HP10C. Well, based on the INTG code instead of INT, I consider that it is for the HP12C.
Best regards.
Luiz (Brazil)
Posts: 6
Threads: 2
Joined: Jan 1970
Hi,
unless I made an error in copying the program, it seems that it does not work for the primes 1, 2, and 3.
Ciao
Alfredo
Posts: 28
Threads: 3
Joined: Dec 2005
Hi Alfredo,
You are absolutely correct. The program does not report 2 or 3 as prime. It is an error that I could have easily corrected. Sorry about that. I did write it for the 12c, but it should work for all of the Voyager calcs. It will probably work for others, but [sigh] I don't have any others to work with.
Thanks for the response. I've tested the program with the prime checker at math.com and gotten perfect results. All responses welcome.
Tony
Posts: 230
Threads: 11
Joined: Jan 1970
Hello, I would no call prime factorization with trial division efficient, but criticizing is easier than programming, so congratulations on your program. The 12C was probably not intended as a tool for number theory explorations...
Posts: 28
Threads: 3
Joined: Dec 2005
Hi GE,
You're not kidding! ;) I sometimes enjoy writing little programs for the 12C to keep my mind agile- and to have a couple of laughs.
Tony