[comp.sys.handhelds] HP28: PrimeQ prog

march@m.cs.uiuc.edu (02/14/90)

This is a *really* cheap primality testing program, PRIMEQ.  The name and 
(apparent) function are analogous to Mathematica's PrimeQ[].  Although
my version isn't in the same ballpark (pun intended).  The domain of their
function is ... well ... to say the least ... quite a bit larger.

PRIMEQ:
<< -> p << 2 p ^ 2 - p MOD >> >>

... where p is the integer to test.

Prime example input:
1:	13

Prime example output:
1:	0

Composite example input:
1:	6

Composite example output:
1:	2

The basic idea is that a return value of 0 indicates a prime and non-zero
return values indicate a composite.  With little effort you will quickly 
see that this only works for p <= 39.  

Oh well, just thought someone might be interested.  

-Steve

===============================================================================
Steve March                            (H) (217)328-5176/328-5230  (W) 333-7408
Domain: march@cs.uiuc.edu             Path: {uunet|convex|pur-ee}!uiucdcs!march
"Time and space are modes by which we think and not conditions in which
 we live."  - Albert Einstein