Prime numbers...



#7

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


#8

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)

#9

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


#10

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


#11

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...


#12

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


Possibly Related Threads…
Thread Author Replies Views Last Post
  HP Prime: complex numbers in CAS. Alberto Candel 1 1,955 12-06-2013, 02:36 PM
Last Post: parisse
  [HP Prime] Plots containing complex numbers bug? Chris Pem10 7 3,718 12-05-2013, 07:40 AM
Last Post: cyrille de Brébisson
  comparing numbers on the WP 34S Kiyoshi Akima 7 2,614 10-19-2013, 09:28 AM
Last Post: walter b
  HP Prime: Operations with Large Numbers Eddie W. Shore 0 997 10-19-2013, 12:24 AM
Last Post: Eddie W. Shore
  HHC 2013 room numbers David Hayden 2 1,344 09-20-2013, 05:34 PM
Last Post: sjthomas
  [HP-Prime xcas] operations with complex numbers + BUGs + Request CompSystems 9 3,566 09-08-2013, 10:40 PM
Last Post: CompSystems
  TED Talk: Adam Spencer: Why I fell in love with monster prime numbers Les Bell 3 1,804 09-05-2013, 12:54 PM
Last Post: Ken Shaw
  Irrationality in numbers....the book Matt Agajanian 4 1,860 08-30-2013, 04:14 PM
Last Post: Matt Agajanian
  Best HP calculator for crunching numbers rpn fan 51 12,917 08-05-2013, 03:17 PM
Last Post: rpn fan
  HP 50G List of Library numbers already in use? Michael Lopez 2 1,280 08-04-2013, 10:10 PM
Last Post: Michael Lopez

Forum Jump: