I want to know another algorithm for checking input a prime number because in the algorithm shown in the lecture it will take so much of the time if the number is large as we have to check every number before the input number. so can you please tell me another method.
Another Algorithm for prime number
One possible approach:
- Check divisibility by small primes up to, say, 5,000. This finds the easy ones.
- Optionally, run a single Fermat test, base 2. This will eliminate some more composites at less cost than a Miller-Rabin test.(you can google these tests but these are part of competitive coding )
- If the number is not yet flagged as composite then run repeated Miller-Rabin tests to the level of accuracy you need. If you run 64 tests then the chances of an error are less than 1 in 2^128.