Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!ux1.cso.uiuc.edu!ux1.cso.uiuc.edu!m.cs.uiuc.edu!march From: march@m.cs.uiuc.edu Newsgroups: comp.sys.handhelds Subject: HP28: PrimeQ prog Message-ID: <50300008@m.cs.uiuc.edu> Date: 14 Feb 90 01:40:02 GMT Lines: 36 Nf-ID: #N:m.cs.uiuc.edu:50300008:000:1080 Nf-From: m.cs.uiuc.edu!march Feb 13 12:29:00 1990 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