Monday 13 October 2014

JAVA PROGRAM TO CHECK FOR PRIMITIVE ROOT OF GIVEN PRIME NUMBER
package pr;
import java.io.*;
public class Pr
{
    public static void main(String[] agrs) throws IOException
   {
     
            DataInputStream ds=new DataInputStream(System.in);
            System.out.println("Enter the value of a large prime no");
            int a=Integer.parseInt(ds.readLine());
            System.out.println("\nEnter the value of alpha");
            int al=Integer.parseInt(ds.readLine());
            int t=1,flag=0;
            t=al;
            for(int i=1;i<a-1;i++)
            {
             t=(t*al)%a;
             if(al==t)
             flag=1;
            }
            if(flag==0)
                System.out.println("primitive roots");
            else
                System.out.println("not primitive roots");
       
}

}