hi ,
i need function to calculate primitive root for prime q
that if i choose prime number q
then a which is primitive must satisfy that
a%q ,(a pow 2 )%q , ...... (a pow i )%q = distinct integers betwwen 1 & q-1
that 1<i < q-1
and i wrote this code but it does not work correctly
#include <iostream.h>
#include <math.h>
main () {
int q ; int a;
cout<<"q : ";
cin>> q ;
cout<<"a : ";
cin>>a;
long int k ;
int s=1 ;
int i=1;
while (s>0 && s<q && i<q )
{
k=pow(a,i);
cout<<"k="<<k<<endl;
s=k%q;
cout<<"s="<<s<<endl;
i++;
}
if ( i==( q))
cout<<"it is primitive "<<endl;
else
cout<<"it is not primitive ";
}
<< moderator edit: added [code][/code] tags >>
so if one can help me , i will be thankx