Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

primitive root

I am writing a program to find the primitive root. In the lecture we have given that

x is a primitive root in F_p, where p a prime number, if
x^((p-1)/pi) is not 1. (With pi the prime factors of p-1).

So here my programm:

R = IntegerModRing(468889)
factor(468889-1)
#gives: p-1 =  2^3 * 3 * 7 * 2791

list = [2,3,7,2791]
c=True

for x in range(1,468889):
  for p in list:
    #Calculate p-1/pi
    a = 468888/p
    k = R(x^a)
    if k==1:
        c=False
    else:
        pass
  if c==True:
    print x
  else:
    pass

But the for loop gives an Error.. Can anyone help? I don't see the problem. Thanks a lot!

primitive root

I am writing a program to find the primitive root. In the lecture we have given that

x is a primitive root in F_p, where p a prime number, if
x^((p-1)/pi) is not 1. (With pi the prime factors of p-1).

So here my programm:

p = 468889
R = IntegerModRing(468889)
factor(468889-1)
IntegerModRing(p)
factor(p-1)
#gives: p-1 =  2^3 * 3 * 7 * 2791

list = [2,3,7,2791]
c=True

(I changed the for loop:)

for x in range(1,468889):
range(1,p):
  for p pi in list:
    #Calculate p-1/pi
    a = 468888/p
a = (p-1)/pi
    if a == int(a):
        k = R(x^a)
     if k==1:
         c=False
        else:
            print k
    else:
        pass
  if c==True:
    print x
  else:
    pass
print c, x

But the for loop gives an Error.. still there is no result. Can anyone help? I don't see the problem. Thanks a lot!