Hey there! Sign in to join this conversationNew here? Join for free

How to prove a number is prime (division method) Watch

    • Thread Starter
    Offline

    7
    ReputationRep:
    Do you divide by just 2,3,5 then 7 or do you have to go up to prime before the square root? For either why do you do this?
    Offline

    19
    ReputationRep:
    Up to the prime before the square root.

    For example if you were to divide 143 only by 2, 3, 5 and 7, you wouldn't see that 143 is in fact divisible by 11 and 13 and so is not a prime.
    • Political Ambassador
    Offline

    3
    ReputationRep:
    Indeed, the simplest primality test is to check if your number n divisible by any m where 2 \leqslant m \leqslant \sqrt{n}

    People have developed other tests but that's the one that everyone uses. :yep:
    Offline

    3
    ReputationRep:
    Wouldn't doing something like a Fermat's little thereom primality test be much more efficient for larger primes?

    Posted from TSR Mobile
    • Thread Starter
    Offline

    7
    ReputationRep:
    (Original post by TheOtherSide.)
    Up to the prime before the square root.

    For example if you were to divide 143 only by 2, 3, 5 and 7, you wouldn't see that 143 is in fact divisible by 11 and 13 and so is not a prime.
    (Original post by Indeterminate)
    Indeed, the simplest primality test is to check if your number n divisible by any m where 2 \leqslant m \leqslant \sqrt{n}

    People have developed other tests but that's the one that everyone uses. :yep:

    Thank you! Why is it up to the square root and not further?

    (Original post by BobBobson)
    Wouldn't doing something like a Fermat's little thereom primality test be much more efficient for larger primes?

    Posted from TSR Mobile
    Not sure I haven't come across it I'm a yr13 student
    • Political Ambassador
    Offline

    3
    ReputationRep:
    (Original post by swagmister)
    Thank you! Why is it up to the square root and not further?
    Observe that if n is not prime, then it can be written as  n = ab for some a and b

    At least one of these must be \leqslant \sqrt{n} otherwise ab > n
    • Thread Starter
    Offline

    7
    ReputationRep:
    (Original post by Indeterminate)
    Observe that if n is not prime, then it can be written as  n = ab for some a and b

    At least one of these must be \leqslant \sqrt{n} otherwise ab > n
    Ah okay thanks!
    Online

    17
    ReputationRep:
    (Original post by Indeterminate)
    Indeed, the simplest primality test is to check if your number n divisible by any m where 2 \leqslant m \leqslant \sqrt{n}

    People have developed other tests but that's the one that everyone uses. :yep:
    Well, not really. Almost anyone using this approach is actually going to check "is n divisible by 2?". If not, check for every odd m with 3 \leqslant m \leqslant \sqrt{n} , which is half the work.

    Of course, this method is hopeless for primality checkijng of large primes.


    (Original post by BobBobson)
    Wouldn't doing something like a Fermat's little thereom primality test be much more efficient for larger primes?
    Unfortunately, this doesn't work; there are numbers that pass Flt for all bases but are not prime. https://en.wikipedia.org/wiki/Carmichael_number

    A somewhat related test that does "work" is Miller-Rabin. This gives absolute proof if tested with enough bases, with computational complexity O((log n)^4) (assuming Generalized Riemann Hypothesis). But for a composite number C, each test to a random base has at least (3/4) chance (*) of showing C is composite, and so the chance of C passing n tests is (3/4)^n. So in practice doing 50 or so tests on C gives you a scenario where if it somehow turned out C was composite, it's more likely something is wrong with the computer than that the tests have failed.

    (*) in practice it's a lot higher. Using the first 6 primes as test-bases is enough to exclude all non-pirmes under 3 trillion.

    Quite recently, an unconditional polynomial time (i.e. polynomial in number of digits of n) algorithm was found (known as the AKS primality test; the initial implementation was O((log n)^12 and this has been improved to O((log n)^6).

    In practice I think people use Miller-Rabin variants for finding primes for RSA encryption et. al.

    There are also specialised tests for numbers of particular forms, this is why we're able to find Mersenne primes (of form 2^n - 1) with much greater efficiency than general primes of similar size.
 
 
 
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • Poll
    What time of year is the worst for students?
    Useful resources

    Make your revision easier

    Maths

    Maths Forum posting guidelines

    Not sure where to post? Read the updated guidelines here

    Equations

    How to use LaTex

    Writing equations the easy way

    Student revising

    Study habits of A* students

    Top tips from students who have already aced their exams

    Study Planner

    Create your own Study Planner

    Never miss a deadline again

    Polling station sign

    Thinking about a maths degree?

    Chat with other maths applicants

    Can you help? Study help unanswered threads

    Groups associated with this forum:

    View associated groups
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

    Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

    Quick reply
    Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.