- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# What are the procedure of Miller-Rabin Primality Testing?

The Miller-Rabin Permality test combines the Fermat test and the Fermat root test in a classic method to find a strong pseudoprime. In this test, it can write n – 1 as the product of an odd number m and a power of 2 −

$$\mathrm{n-1=m\, x\, 2^{k}}$$

The Fermat test in base a can be composed as −

$$\mathrm{a^{n-1}\, =\, a^{m\, x\, 2k}=\left [ a^{m} \right ]^{2k}=\left [ a^{m} \right ]\frac{2^{2}\cdot \cdot \cdot 2}{K\, times}}$$

In other words, rather than calculating a^{n−1}(mod n) in one step, it can do it in k+1 steps. The advantage of using k + 1 is that each step in the square root step can be implemented. If the square root test fails, it can stop and declare n as a composite number.

In each step, it can provide that the Fermat test is passed and the square root test is satisfied among all group of adjacent steps, if accessible (if the result is 1).

### Initialization

It can select a base a and calculate $\mathrm{T\, =\, a^{m}}$ ,in which $\mathrm{m\, =\, \frac{n-1}{2^{k}}}$

If T is + 1 or -1 declare that n is a strong pseudoprime and stop. Because if T is +-1, T will become 1 in the next step and remain 1 until it passes the Fermat test. Moreover, T has passed the square root test because T can be 1 in the next step and the square root of 1 (in the next step) is +-1.

If T is anything else, it is not sure if n is a prime or a composite, so it can continue to the next step.

**Step1**: We square T

If the result is +1, it is definitely known that the Fermat test will be passed because T remains 1 for the succeeding tests. The square root test has not been passed. Because T is 1 in this step and was something other than +-1 in the previous step it can declare n as composite and stop.

If the result is -1, it can understand that n will eventually pass the Fermat test. It can also understand that it will pass the square root test because T is -1 in this step and becomes 1 in the next step. It can declare n as strong pseudoprime and stop.

If T is anything else, it is not sure whether it can do or do not have a prime. It continue to the next step.

**Step2 to Step K – 1:**

This step and all following steps keeps on continuing until step 2 and till step K -1 are equal as step 1.

**Step K:**

This step is not required. If it can have reached this step and it have not create a decision, this step will not provide us. If the result of this step is 1, the Fermat test is accepted, but because the result of the previous step is not +-1, the square root test is not accepted. After step k -1, if it have not already stopped, it can declare that n is composite. The Miller-Rabin test required from step 0 to step K-1.

- Related Questions & Answers
- What are the Miller-Rabin Algorithm for testing the primality of a given number?
- C++ Program to Implement the Rabin-Miller Primality Test to Check if a Given Number is Prime
- What is Primality Testing in Information Security?
- What are the key assumptions of Modigliani-Miller (M&M) Theorem?
- What are the assumptions of Miller and Modigliani's Dividend Irrelevance Model?
- What are Different Types of Testing?
- Criticism of the Modigliani-Miller (MM) Hypothesis
- Rabin-Karp Algorithm
- What are the different modes of parameters used by MySQL stored procedure?
- What are Destructive Testing and Nondestructive Testing? (Techniques, Methods, Example)
- What are the limitations for replicating stored procedure and functions?
- Primality test of numbers in JavaScript
- What are the benefits of using Selenium as an Automation Testing tool?
- Primality Test in C++
- What is the job costing procedure?