Math Is Fun Forum
  Discussion about math, puzzles, games and fun.   Useful symbols: √ ∞ ≠ ≤ ≥ ≈ ⇒ ∈ Δ θ ∴ ∑ ∫ π -




Not registered yet?

Post a reply

Go back

Write your message and submit
:) :| :( :D :o ;) :/ :P :lol: :mad: :rolleyes: :cool: | :dizzy :eek :kiss :roflol :rolleyes :shame :down :up :touched :sleep :wave :swear :tongue :what :faint :dunno

Go back

Topic review (newest first)

2010-07-20 17:35:45

That is the fastest for an exact answer concerning primality. If you use the probabilistic RM and run through the algorithm say 15
times you would have a probability less than .000 000 000 931 that the number is not prime.

2010-07-20 11:10:36


2010-07-20 10:45:39

Hi cal;

You do know that the fastest deterministic test is the new one invented by those 3 Indian mathematicians and will determine the status of a number with 1000 digits in about 1 hour on a modern desktop.

This is the fastest known.

2010-07-20 09:29:20

yeah. just testing if the number is prime

2010-07-20 08:57:59

Depends what are you trying to do? Primality testing? What?

2010-07-20 07:49:02

is there a better and faster method of testing?

2010-07-20 04:41:05


Yes, but which part is using most of the time. That's the part you try to speed up.

2010-07-20 04:23:27

I think the bottleneck is the testing itself. Oh well. No matter. I'll eventually figure this out.

Thanks bobbym

2010-07-20 01:15:36

Hi cal;

It may not be possible with numbers that large. Those are really large.  Where is the bottleneck? Have you wrapped pieces of the code with timers to see which part is the slowest?

Also being a probabilistic primality tester each iteration reduces the probability that the number is composite by a factor of 4. So after only a couple of iterations you will have a number that is very likely to be prime. You will not have certainty.

2010-07-20 00:47:44

yep, which is why i want to try to speed up the testing a bit

2010-07-19 14:10:01


2^3072 are 1000 digit numbers, maybe that's where the slow down is.

2010-07-19 11:43:49

no. i guess my comment was a bit vague

i might as well put the real code:


    p = randint(3, 2**L)
    p = q * (1 + p/q) + 1
    while MillerRabin(p) == False:                # prime = True, composite = False
        p = p + q

miller rabin is not what im creating. rather, it is another function that im using to test my p values, and it is the probabilistic test.

the L value can be 1024,2048, or 3072

2010-07-19 11:29:11


Isn't this a Rabin Miller primality tester? It has been 15 years since I have done any computerized primality testing but this reminds me of the deterministec form of Miller Rabin?!

If I am not in error then I must say this test is much slower than the probabilitic version of it. So how big are the numbers you are trying to test for primality?

2010-07-19 11:18:20

well the entire code block is just a pseudo code, but randint (which is also a legitimate command) is supposed to returns a random integer between a and b, inclusive. the real code is barely any different

2010-07-19 11:11:54

Hi calccrypto;

A question: Is randint(a,b) that you are using a python command? If so what does it return?

Board footer

Powered by FluxBB