Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #8621
| From | David Bailey <dave@removedbailey.co.uk> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Need help with prime Test |
| Date | 2012-02-19 11:35 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jhqmpu$fbc$1@smc.vnet.net> (permalink) |
| References | <jh6kd9$jsp$1@smc.vnet.net> |
On 11/02/2012 20:51, KenR wrote: > I need to generate more "Ramsey" Numbers to further verify that only > prime numbers can meet the criteria. Ramsey numbers are those > generated from a simple criteria that is easy to check. I imported a > CSV list into my Mathematica version 8 to check all 30,759 numbers > that my Excel macro selected and they all turned out to be prime. That > is all that my program selected from all odd numbers from 3 to > 1,048,655, as large as my Excel program could test. I would further > test my program using my Mathematica software but I would like some > help to write the most efficient program to do the job. Right now, I > am trying to write a while loop inside a do loop but don't know how to > exit the loop before the counter becomes 0 in the case that it is > clear that P is not prime. > > The check is to do the following binary recursive sequence mod P and > check to see that the (P-1)/2 term is zero and no term prior to that > is zero. If so then I believe P should be prime based upon the results > so far. > > The test sequence is S(0) = 2, S(1) = 3, S(n) = 6*S(n-1) - S(n-2) - 6. > It appears that S((P-1)/2) is divisible by P then P is very likely > Prime, but I am interested in a test that is valid only for primes. > S((35-1)/2) is divisible by 35 but that is not the first term > divisible by 35. Only about 1/3 of the primes seem to meet the more > restricted criteria, i.e. the sequence has no term divisible by P > prior to S((P-1)/2). > > Using Do and While loops, tends to be frowned upon by some purists, but I think they are a good way to take a first stab at many problems. To exit a Do or While loop on some condition, use If[condition,Break[]]; If you want to exit multiple layers of loops, and/or function calls, use Catch/Throw. These are inefficient if used, but if you are going to execute them at most once, there is no problem. David Bailey http://www.dbaileyconsultancy.co.uk
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread
Need help with prime Test KenR <ramsey2879@msn.com> - 2012-02-11 20:51 +0000 Re: Need help with prime Test "Oleksandr Rasputinov" <oleksandr_rasputinov@ymail.com> - 2012-02-12 10:05 +0000 Re: Need help with prime Test David Bailey <dave@removedbailey.co.uk> - 2012-02-19 11:35 +0000
csiph-web