SharedPub.ipynbOpen in CoCalc
def LC(p,q,g):
    f = mod(g,p).crt(mod(1,q)); K.<x> = GF(2)[]
    d = gcd(p-1,q-1); e = (p-1)*(q-1)/d; S = 0
    for i in range(d/2,d):
        for t in range(e/d):
            gidt = g^(i+d*t)
            for v in range(d): S = S + x^((gidt * f^v)%(p*q))
        for t in range((p-1)/d): S = S + x^(q * (g^(i+d*t)%p))
        for t in range((q-1)/d): S = S + x^(p * (g^(i+d*t)%q))
    return p*q - gcd(x^(p*q)-1,S).degree()

def L(p,q):
    rp = mod(2,p).log(); rq = mod(2,q).log(); rpq = mod(p,q).log();
    L = p*q - 1
    if rq%8==0: L = L - (q-1)/2
    if rp%8==0:
        L = L - (p-1)/2
        if rq%4==0 or rpq%4==0: L = L - (p-1)*(q-1)/2
    if rp%8==4 and rq%4!=0 and rpq%4==2: L = L - (p-1)*(q-1)/2
    if rp%4==0 and rq%4!=0 and rpq%2==1: L = L - (p-1)*(q-1)/4
    return L

D = 1000; import random
for p in prime_range(D):
    for q in prime_range(p,D):
        if gcd(p-1,q-1) != 8: continue
        Lpq = L(p,q); Lqp = L(q,p)
        R = random.randint(0,p*q)
        for g in range(R,R+p*q):
            mp = mod(g,p).is_primitive_root()
            mq = mod(g,q).is_primitive_root()
            if mp == mq == True: break
        if LC(p,q,g) != Lpq:
            print ("Wrong for p = %s, q = %s, g = %s" % (p,q,g))
        if LC(q,p,g) != Lqp:
            print ("Wrong for p = %s, q = %s, g = %s" % (q,p,g))
        else:
            print ("p=%3s, q=%3s, g=%6s, L(p,q)=%6s, L(q,p)=%6s" %
                   (p,q,g,Lpq,Lqp))
p= 17, q= 41, g= 334, L(p,q)= 696, L(q,p)= 696 p= 17, q= 73, g= 921, L(p,q)= 1204, L(q,p)= 916 p= 17, q= 89, g= 1049, L(p,q)= 1468, L(q,p)= 764 p= 17, q=137, g= 2081, L(p,q)= 2328, L(q,p)= 2328 p= 17, q=233, g= 260, L(p,q)= 3844, L(q,p)= 2916 p= 17, q=281, g= 465, L(p,q)= 4776, L(q,p)= 2536 p= 17, q=313, g= 2776, L(p,q)= 5320, L(q,p)= 5320 p= 17, q=409, g= 2152, L(p,q)= 6952, L(q,p)= 6952 p= 17, q=457, g= 4903, L(p,q)= 7768, L(q,p)= 7768 p= 17, q=521, g= 107, L(p,q)= 8856, L(q,p)= 8856 p= 17, q=569, g= 7500, L(p,q)= 9672, L(q,p)= 9672 p= 17, q=601, g= 6421, L(p,q)= 9916, L(q,p)= 7516 p= 17, q=617, g= 6862, L(p,q)= 10488, L(q,p)= 8024 p= 17, q=761, g= 2867, L(p,q)= 12936, L(q,p)= 12936 p= 17, q=809, g= 10500, L(p,q)= 13752, L(q,p)= 13752 p= 17, q=857, g= 5860, L(p,q)= 14568, L(q,p)= 14568 p= 17, q=937, g= 1943, L(p,q)= 15460, L(q,p)= 15460 p= 17, q=953, g= 2594, L(p,q)= 16200, L(q,p)= 16200 p= 41, q= 73, g= 1400, L(p,q)= 2956, L(q,p)= 2956 p= 41, q= 89, g= 3456, L(p,q)= 3604, L(q,p)= 2724 p= 41, q= 97, g= 526, L(p,q)= 3976, L(q,p)= 3976 p= 41, q=113, g= 3041, L(p,q)= 4632, L(q,p)= 4632 p= 41, q=137, g= 3138, L(p,q)= 5616, L(q,p)= 5616 p= 41, q=193, g= 7891, L(p,q)= 7912, L(q,p)= 7912 p= 41, q=233, g= 1819, L(p,q)= 9436, L(q,p)= 7116 p= 41, q=257, g= 2231, L(p,q)= 10408, L(q,p)= 7848 p= 41, q=313, g= 4640, L(p,q)= 12832, L(q,p)= 12832 p= 41, q=337, g= 2432, L(p,q)= 13648, L(q,p)= 13648 p= 41, q=353, g= 2208, L(p,q)= 14472, L(q,p)= 14472 p= 41, q=409, g= 140, L(p,q)= 16768, L(q,p)= 16768 p= 41, q=433, g= 10468, L(p,q)= 17752, L(q,p)= 17752 p= 41, q=449, g= 4394, L(p,q)= 18408, L(q,p)= 18408 p= 41, q=457, g= 18588, L(p,q)= 18736, L(q,p)= 18736 p= 41, q=569, g= 21670, L(p,q)= 23328, L(q,p)= 23328 p= 41, q=577, g= 12773, L(p,q)= 23656, L(q,p)= 17896 p= 41, q=593, g= 20547, L(p,q)= 24312, L(q,p)= 18392 p= 41, q=617, g= 7104, L(p,q)= 25296, L(q,p)= 12976 p= 41, q=673, g= 20775, L(p,q)= 27592, L(q,p)= 27592 p= 41, q=769, g= 13754, L(p,q)= 31528, L(q,p)= 31528 p= 41, q=809, g= 15286, L(p,q)= 33168, L(q,p)= 33168 p= 41, q=857, g= 32957, L(p,q)= 35136, L(q,p)= 35136 p= 41, q=929, g= 30683, L(p,q)= 38088, L(q,p)= 38088 p= 41, q=937, g= 27166, L(p,q)= 37948, L(q,p)= 28588 p= 41, q=953, g= 7477, L(p,q)= 39072, L(q,p)= 39072 p= 41, q=977, g= 4270, L(p,q)= 40056, L(q,p)= 40056 p= 73, q= 89, g= 3280, L(p,q)= 3248, L(q,p)= 3248 p= 73, q=113, g= 4804, L(p,q)= 4180, L(q,p)= 8212 p= 73, q=137, g= 208, L(p,q)= 5068, L(q,p)= 9964 p= 73, q=233, g= 16657, L(p,q)= 8504, L(q,p)= 8504 p= 73, q=257, g= 2542, L(p,q)= 9380, L(q,p)= 9380 p= 73, q=281, g= 12657, L(p,q)= 10396, L(q,p)= 20476 p= 73, q=353, g= 22604, L(p,q)= 13060, L(q,p)= 25732 p= 73, q=401, g= 26479, L(p,q)= 29236, L(q,p)= 29236 p= 73, q=449, g= 28410, L(p,q)= 24676, L(q,p)= 32740 p= 73, q=521, g= 6179, L(p,q)= 28636, L(q,p)= 37996 p= 73, q=569, g= 4610, L(p,q)= 31276, L(q,p)= 41500 p= 73, q=593, g= 27234, L(p,q)= 21940, L(q,p)= 43252 p= 73, q=617, g= 17768, L(p,q)= 22828, L(q,p)= 45004 p= 73, q=641, g= 10209, L(p,q)= 46756, L(q,p)= 46756 p= 73, q=761, g= 10742, L(p,q)= 41836, L(q,p)= 55516 p= 73, q=809, g= 12828, L(p,q)= 29932, L(q,p)= 59020 p= 73, q=857, g= 54171, L(p,q)= 62524, L(q,p)= 62524 p= 73, q=881, g= 27678, L(p,q)= 32156, L(q,p)= 32156 p= 73, q=929, g= 51989, L(p,q)= 51076, L(q,p)= 67780 p= 73, q=953, g= 46627, L(p,q)= 69532, L(q,p)= 69532 p= 73, q=977, g= 3783, L(p,q)= 53716, L(q,p)= 71284 p= 89, q= 97, g= 7139, L(p,q)= 8588, L(q,p)= 8588 p= 89, q=113, g= 7235, L(p,q)= 5084, L(q,p)= 10012 p= 89, q=137, g= 4830, L(p,q)= 9156, L(q,p)= 12148 p= 89, q=193, g= 17074, L(p,q)= 12908, L(q,p)= 17132 p= 89, q=233, g= 9796, L(p,q)= 10368, L(q,p)= 10368 p= 89, q=241, g= 2878, L(p,q)= 16124, L(q,p)= 21404 p= 89, q=257, g= 3138, L(p,q)= 11436, L(q,p)= 11436 p= 89, q=281, g= 3494, L(p,q)= 12644, L(q,p)= 24964 p= 89, q=313, g= 25629, L(p,q)= 20948, L(q,p)= 27812 p= 89, q=337, g= 4117, L(p,q)= 14996, L(q,p)= 14996 p= 89, q=401, g= 24953, L(p,q)= 35644, L(q,p)= 35644 p= 89, q=409, g= 21532, L(p,q)= 18404, L(q,p)= 36356 p= 89, q=433, g= 23377, L(p,q)= 28988, L(q,p)= 38492 p= 89, q=449, g= 3967, L(p,q)= 20204, L(q,p)= 39916 p= 89, q=457, g= 20209, L(p,q)= 30596, L(q,p)= 40628 p= 89, q=521, g= 23325, L(p,q)= 34884, L(q,p)= 46324 p= 89, q=569, g= 29154, L(p,q)= 38100, L(q,p)= 50596 p= 89, q=577, g= 4067, L(p,q)= 25964, L(q,p)= 51308 p= 89, q=593, g= 4097, L(p,q)= 26684, L(q,p)= 52732 p= 89, q=601, g= 35987, L(p,q)= 26744, L(q,p)= 26744 p= 89, q=641, g= 34478, L(p,q)= 57004, L(q,p)= 57004 p= 89, q=673, g= 58556, L(p,q)= 59852, L(q,p)= 59852 p= 89, q=761, g= 34829, L(p,q)= 34244, L(q,p)= 67684 p= 89, q=769, g= 45862, L(p,q)= 68396, L(q,p)= 68396 p= 89, q=809, g= 40472, L(p,q)= 36404, L(q,p)= 71956 p= 89, q=857, g= 69903, L(p,q)= 57396, L(q,p)= 76228 p= 89, q=929, g= 67121, L(p,q)= 41804, L(q,p)= 82636 p= 89, q=937, g= 47341, L(p,q)= 41696, L(q,p)= 41696 p= 89, q=953, g= 71452, L(p,q)= 63828, L(q,p)= 84772 p= 89, q=977, g= 65341, L(p,q)= 43964, L(q,p)= 86908 p= 97, q=137, g= 11839, L(p,q)= 13288, L(q,p)= 13288 p= 97, q=233, g= 22192, L(p,q)= 22484, L(q,p)= 16916 p= 97, q=281, g= 15333, L(p,q)= 27256, L(q,p)= 20536 p= 97, q=521, g= 22481, L(p,q)= 50536, L(q,p)= 50536 p= 97, q=569, g= 15506, L(p,q)= 55192, L(q,p)= 55192 p= 97, q=617, g= 48653, L(p,q)= 59848, L(q,p)= 59848 p= 97, q=761, g= 52533, L(p,q)= 73816, L(q,p)= 73816 p= 97, q=809, g= 61170, L(p,q)= 78472, L(q,p)= 78472 p= 97, q=857, g= 55749, L(p,q)= 83128, L(q,p)= 83128 p= 97, q=953, g= 18938, L(p,q)= 92440, L(q,p)= 92440 p=113, q=137, g= 13175, L(p,q)= 11672, L(q,p)= 15480 p=113, q=233, g= 9198, L(p,q)= 26212, L(q,p)= 13220 p=113, q=313, g= 14102, L(p,q)= 35368, L(q,p)= 35368 p=113, q=409, g= 27287, L(p,q)= 34792, L(q,p)= 46216 p=113, q=457, g= 37307, L(p,q)= 38872, L(q,p)= 51640 p=113, q=521, g= 43065, L(p,q)= 29752, L(q,p)= 58872 p=113, q=569, g= 29594, L(p,q)= 64296, L(q,p)= 64296 p=113, q=601, g= 27688, L(p,q)= 67612, L(q,p)= 34012 p=113, q=761, g= 16248, L(p,q)= 43432, L(q,p)= 85992 p=113, q=809, g= 67541, L(p,q)= 91416, L(q,p)= 91416 p=113, q=857, g= 64929, L(p,q)= 72872, L(q,p)= 96840 p=113, q=937, g= 48438, L(p,q)=105412, L(q,p)= 52996 p=137, q=193, g= 6249, L(p,q)= 26440, L(q,p)= 26440 p=137, q=233, g= 15282, L(p,q)= 31804, L(q,p)= 23916 p=137, q=241, g= 3960, L(p,q)= 33016, L(q,p)= 33016 p=137, q=257, g= 28554, L(p,q)= 35080, L(q,p)= 35080 p=137, q=281, g= 16256, L(p,q)= 38496, L(q,p)= 19456 p=137, q=313, g= 21222, L(p,q)= 42880, L(q,p)= 42880 p=137, q=337, g= 6022, L(p,q)= 46000, L(q,p)= 23152 p=137, q=353, g= 45021, L(p,q)= 48360, L(q,p)= 36392 p=137, q=401, g= 15998, L(p,q)= 54936, L(q,p)= 54936 p=137, q=433, g= 38750, L(p,q)= 59320, L(q,p)= 59320 p=137, q=449, g= 725, L(p,q)= 61512, L(q,p)= 61512 p=137, q=457, g= 60678, L(p,q)= 62608, L(q,p)= 62608 p=137, q=521, g= 22570, L(p,q)= 71376, L(q,p)= 71376 p=137, q=569, g= 36758, L(p,q)= 77952, L(q,p)= 77952 p=137, q=577, g= 43512, L(p,q)= 79048, L(q,p)= 59464 p=137, q=593, g= 48854, L(p,q)= 81240, L(q,p)= 61112 p=137, q=601, g= 36213, L(p,q)= 82036, L(q,p)= 61636 p=137, q=617, g= 40775, L(p,q)= 84528, L(q,p)= 42640 p=137, q=641, g= 70030, L(p,q)= 87816, L(q,p)= 87816 p=137, q=673, g= 27210, L(p,q)= 92200, L(q,p)= 92200 p=137, q=761, g= 52582, L(p,q)=104256, L(q,p)=104256 p=137, q=769, g= 57005, L(p,q)=105352, L(q,p)=105352 p=137, q=809, g= 27784, L(p,q)=110832, L(q,p)=110832 p=137, q=857, g= 55342, L(p,q)=117408, L(q,p)=117408 p=137, q=881, g= 90536, L(p,q)=120256, L(q,p)= 60416 p=137, q=929, g= 30997, L(p,q)=127272, L(q,p)=127272 p=137, q=937, g=109763, L(p,q)=127900, L(q,p)= 64252 p=137, q=977, g= 14761, L(p,q)=133848, L(q,p)=133848 p=193, q=233, g= 12189, L(p,q)= 44852, L(q,p)= 33716 p=193, q=281, g= 35913, L(p,q)= 54232, L(q,p)= 40792 p=193, q=521, g= 29061, L(p,q)=100552, L(q,p)=100552 p=193, q=569, g= 91251, L(p,q)=109816, L(q,p)=109816 p=193, q=617, g= 5733, L(p,q)=119080, L(q,p)= 89512 p=193, q=761, g= 65375, L(p,q)=146872, L(q,p)=146872 p=193, q=809, g=111107, L(p,q)=156136, L(q,p)=156136 p=193, q=857, g= 69510, L(p,q)=165400, L(q,p)=165400 p=193, q=953, g=132765, L(p,q)=183928, L(q,p)=183928 p=233, q=241, g= 27460, L(p,q)= 56036, L(q,p)= 56036 p=233, q=257, g= 14523, L(p,q)= 29940, L(q,p)= 29940 p=233, q=281, g= 23993, L(p,q)= 32876, L(q,p)= 65356 p=233, q=313, g= 5412, L(p,q)= 54716, L(q,p)= 72812 p=233, q=337, g= 61195, L(p,q)= 39260, L(q,p)= 39260 p=233, q=353, g= 67546, L(p,q)= 41300, L(q,p)= 82132 p=233, q=401, g= 40728, L(p,q)= 70116, L(q,p)= 93316 p=233, q=409, g= 15563, L(p,q)= 71516, L(q,p)= 95180 p=233, q=433, g= 4748, L(p,q)= 50660, L(q,p)=100772 p=233, q=449, g= 73900, L(p,q)= 78516, L(q,p)=104500 p=233, q=457, g= 2801, L(p,q)=106364, L(q,p)=106364 p=233, q=521, g= 54527, L(p,q)= 60956, L(q,p)=121276 p=233, q=569, g=119468, L(p,q)= 99516, L(q,p)=132460 p=233, q=577, g= 21309, L(p,q)= 67508, L(q,p)=134324 p=233, q=593, g=102595, L(p,q)= 69380, L(q,p)=138052 p=233, q=601, g= 91418, L(p,q)= 70016, L(q,p)= 70016 p=233, q=617, g= 14981, L(p,q)= 72188, L(q,p)=143644 p=233, q=641, g= 31029, L(p,q)= 74996, L(q,p)=149236 p=233, q=673, g=120652, L(p,q)=156692, L(q,p)=156692 p=233, q=761, g= 38376, L(p,q)= 89036, L(q,p)=177196 p=233, q=769, g= 20017, L(p,q)=134516, L(q,p)=179060 p=233, q=809, g= 4730, L(p,q)=188380, L(q,p)=188380 p=233, q=857, g=160913, L(p,q)=149916, L(q,p)=199564 p=233, q=881, g= 1853, L(p,q)=102636, L(q,p)=102636 p=233, q=937, g=162768, L(p,q)=109160, L(q,p)=109160 p=233, q=953, g=190635, L(p,q)=166716, L(q,p)=221932 p=233, q=977, g= 12296, L(p,q)=170916, L(q,p)=227524 p=241, q=569, g= 2095, L(p,q)=137128, L(q,p)=137128 p=241, q=617, g= 68759, L(p,q)=148696, L(q,p)=148696 p=241, q=809, g=111185, L(p,q)=194968, L(q,p)=194968 p=241, q=857, g= 47705, L(p,q)=206536, L(q,p)=206536 p=241, q=953, g=134905, L(p,q)=229672, L(q,p)=229672 p=257, q=281, g= 22630, L(p,q)= 36248, L(q,p)= 72088 p=257, q=313, g= 39597, L(p,q)= 60344, L(q,p)= 80312 p=257, q=409, g= 69414, L(p,q)= 78872, L(q,p)=104984 p=257, q=457, g=116581, L(p,q)= 58952, L(q,p)=117320 p=257, q=521, g=133289, L(p,q)=100488, L(q,p)=133768 p=257, q=569, g= 86683, L(p,q)=109752, L(q,p)=146104 p=257, q=601, g= 95117, L(p,q)= 77228, L(q,p)= 77228 p=257, q=617, g= 40397, L(p,q)= 79592, L(q,p)=158440 p=257, q=761, g= 94388, L(p,q)=146808, L(q,p)=195448 p=257, q=809, g=135202, L(p,q)=156072, L(q,p)=207784 p=257, q=857, g=158608, L(p,q)=165336, L(q,p)=220120 p=257, q=937, g= 88975, L(p,q)=120404, L(q,p)=120404 p=257, q=953, g= 1643, L(p,q)=183864, L(q,p)=244792 p=281, q=313, g= 4881, L(p,q)= 44272, L(q,p)= 87952 p=281, q=353, g= 26930, L(p,q)= 99192, L(q,p)= 99192 p=281, q=409, g= 77908, L(p,q)= 57808, L(q,p)=114928 p=281, q=433, g= 34654, L(p,q)= 91432, L(q,p)=121672 p=281, q=457, g= 80233, L(p,q)= 96496, L(q,p)=128416 p=281, q=569, g= 34680, L(p,q)=159888, L(q,p)=159888 p=281, q=577, g= 81649, L(p,q)=162136, L(q,p)=162136 p=281, q=593, g= 96072, L(p,q)=166632, L(q,p)=166632 p=281, q=769, g=136416, L(p,q)=162328, L(q,p)=216088 p=281, q=809, g= 18276, L(p,q)=227328, L(q,p)=227328 p=281, q=857, g=133018, L(p,q)=120976, L(q,p)=240816 p=281, q=929, g=164544, L(p,q)=131128, L(q,p)=261048 p=281, q=937, g= 28838, L(p,q)=262828, L(q,p)=131788
D = 1000; i = 0
for p in prime_range(D):
    for q in prime_range(p,D):
        if gcd(p-1,q-1) != 8: continue
        Lpq = L(p,q); Lqp = L(q,p)
        i = i + 1
        if i%3 == 0: print("%s & %s & %s & %s \\tabularnewline" % (p,q,Lpq,Lqp))
        else: print("%s & %s & %s & %s & &" % (p,q,Lpq,Lqp))
if i%3 == 1: print(" & & & & & & & & \\tabularnewline")
if i%3 == 2: print(" & & & \\tabularnewline")
--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-2-91339397b87b> in <module>() 3 for q in prime_range(p,D): 4 if gcd(p-Integer(1),q-Integer(1)) != Integer(8): continue ----> 5 Lpq = L(p,q); Lqp = L(q,p) 6 i = i + Integer(1) 7 if i%Integer(3) == Integer(0): print("%s & %s & %s & %s \\tabularnewline" % (p,q,Lpq,Lqp)) NameError: name 'L' is not defined
89 & 313 & 20948 & 27812 \tabularnewline 89 & 337 & 14996 & 14996 & & 89 & 401 & 35644 & 35644 & & 89 & 409 & 18404 & 36356 \tabularnewline 89 & 433 & 28988 & 38492 & & 89 & 449 & 20204 & 39916 & & 89 & 457 & 30596 & 40628 \tabularnewline 89 & 521 & 34884 & 46324 & & 89 & 569 & 38100 & 50596 & & 89 & 577 & 25964 & 51308 \tabularnewline 89 & 593 & 26684 & 52732 & & 89 & 601 & 26744 & 26744 & & 89 & 641 & 57004 & 57004 \tabularnewline 89 & 673 & 59852 & 59852 & & 89 & 761 & 34244 & 67684 & & 89 & 769 & 68396 & 68396 \tabularnewline 89 & 809 & 36404 & 71956 & & 89 & 857 & 57396 & 76228 & & 89 & 929 & 41804 & 82636 \tabularnewline 89 & 937 & 41696 & 41696 & & 89 & 953 & 63828 & 84772 & & 89 & 977 & 43964 & 86908 \tabularnewline 97 & 137 & 13288 & 13288 & & 97 & 233 & 22484 & 16916 & & 97 & 281 & 27256 & 20536 \tabularnewline 97 & 521 & 50536 & 50536 & & 97 & 569 & 55192 & 55192 & & 97 & 617 & 59848 & 59848 \tabularnewline 97 & 761 & 73816 & 73816 & & 97 & 809 & 78472 & 78472 & & 97 & 857 & 83128 & 83128 \tabularnewline 97 & 953 & 92440 & 92440 & & 113 & 137 & 11672 & 15480 & & 113 & 233 & 26212 & 13220 \tabularnewline 113 & 313 & 35368 & 35368 & & 113 & 409 & 34792 & 46216 & & 113 & 457 & 38872 & 51640 \tabularnewline 113 & 521 & 29752 & 58872 & & 113 & 569 & 64296 & 64296 & & 113 & 601 & 67612 & 34012 \tabularnewline 113 & 761 & 43432 & 85992 & & 113 & 809 & 91416 & 91416 & & 113 & 857 & 72872 & 96840 \tabularnewline 113 & 937 & 105412 & 52996 & & 137 & 193 & 26440 & 26440 & & 137 & 233 & 31804 & 23916 \tabularnewline 137 & 241 & 33016 & 33016 & & 137 & 257 & 35080 & 35080 & & 137 & 281 & 38496 & 19456 \tabularnewline 137 & 313 & 42880 & 42880 & & 137 & 337 & 46000 & 23152 & & 137 & 353 & 48360 & 36392 \tabularnewline 137 & 401 & 54936 & 54936 & & 137 & 433 & 59320 & 59320 & & 137 & 449 & 61512 & 61512 \tabularnewline 137 & 457 & 62608 & 62608 & & 137 & 521 & 71376 & 71376 & & 137 & 569 & 77952 & 77952 \tabularnewline 137 & 577 & 79048 & 59464 & & 137 & 593 & 81240 & 61112 & & 137 & 601 & 82036 & 61636 \tabularnewline 137 & 617 & 84528 & 42640 & & 137 & 641 & 87816 & 87816 & & 137 & 673 & 92200 & 92200 \tabularnewline 137 & 761 & 104256 & 104256 & & 137 & 769 & 105352 & 105352 & & 137 & 809 & 110832 & 110832 \tabularnewline 137 & 857 & 117408 & 117408 & & 137 & 881 & 120256 & 60416 & & 137 & 929 & 127272 & 127272 \tabularnewline 137 & 937 & 127900 & 64252 & & 137 & 977 & 133848 & 133848 & & 193 & 233 & 44852 & 33716 \tabularnewline 193 & 281 & 54232 & 40792 & & 193 & 521 & 100552 & 100552 & & 193 & 569 & 109816 & 109816 \tabularnewline 193 & 617 & 119080 & 89512 & & 193 & 761 & 146872 & 146872 & & 193 & 809 & 156136 & 156136 \tabularnewline 193 & 857 & 165400 & 165400 & & 193 & 953 & 183928 & 183928 & & 233 & 241 & 56036 & 56036 \tabularnewline 233 & 257 & 29940 & 29940 & & 233 & 281 & 32876 & 65356 & & 233 & 313 & 54716 & 72812 \tabularnewline 233 & 337 & 39260 & 39260 & & 233 & 353 & 41300 & 82132 & & 233 & 401 & 70116 & 93316 \tabularnewline 233 & 409 & 71516 & 95180 & & 233 & 433 & 50660 & 100772 & & 233 & 449 & 78516 & 104500 \tabularnewline 233 & 457 & 106364 & 106364 & & 233 & 521 & 60956 & 121276 & & 233 & 569 & 99516 & 132460 \tabularnewline 233 & 577 & 67508 & 134324 & & 233 & 593 & 69380 & 138052 & & 233 & 601 & 70016 & 70016 \tabularnewline 233 & 617 & 72188 & 143644 & & 233 & 641 & 74996 & 149236 & & 233 & 673 & 156692 & 156692 \tabularnewline 233 & 761 & 89036 & 177196 & & 233 & 769 & 134516 & 179060 & & 233 & 809 & 188380 & 188380 \tabularnewline 233 & 857 & 149916 & 199564 & & 233 & 881 & 102636 & 102636 & & 233 & 937 & 109160 & 109160 \tabularnewline 233 & 953 & 166716 & 221932 & & 233 & 977 & 170916 & 227524 & & 241 & 569 & 137128 & 137128 \tabularnewline 241 & 617 & 148696 & 148696 & & 241 & 809 & 194968 & 194968 & & 241 & 857 & 206536 & 206536 \tabularnewline 241 & 953 & 229672 & 229672 & & 257 & 281 & 36248 & 72088 & & 257 & 313 & 60344 & 80312 \tabularnewline 257 & 409 & 78872 & 104984 & & 257 & 457 & 58952 & 117320 & & 257 & 521 & 100488 & 133768 \tabularnewline 257 & 569 & 109752 & 146104 & & 257 & 601 & 77228 & 77228 & & 257 & 617 & 79592 & 158440 \tabularnewline 257 & 761 & 146808 & 195448 & & 257 & 809 & 156072 & 207784 & & 257 & 857 & 165336 & 220120 \tabularnewline 257 & 937 & 120404 & 120404 & & 257 & 953 & 183864 & 244792 & & 281 & 313 & 44272 & 87952 \tabularnewline 281 & 353 & 99192 & 99192 & & 281 & 409 & 57808 & 114928 & & 281 & 433 & 91432 & 121672 \tabularnewline 281 & 457 & 96496 & 128416 & & 281 & 569 & 159888 & 159888 & & 281 & 577 & 162136 & 162136 \tabularnewline 281 & 593 & 166632 & 166632 & & 281 & 769 & 162328 & 216088 & & 281 & 809 & 227328 & 227328 \tabularnewline 281 & 857 & 120976 & 240816 & & 281 & 929 & 131128 & 261048 & & 281 & 937 & 262828 & 131788 \tabularnewline 281 & 977 & 206216 & 274536 & & 313 & 353 & 110488 & 83032 & & 313 & 401 & 125512 & 125512 \tabularnewline 313 & 449 & 140536 & 140536 & & 313 & 569 & 178096 & 178096 & & 313 & 593 & 185608 & 185608 \tabularnewline 313 & 617 & 193120 & 193120 & & 313 & 641 & 200632 & 200632 & & 313 & 761 & 238192 & 238192 \tabularnewline 313 & 809 & 253216 & 253216 & & 313 & 857 & 268240 & 268240 & & 313 & 881 & 275312 & 138032 \tabularnewline 313 & 929 & 290776 & 290776 & & 313 & 953 & 298288 & 298288 & & 313 & 977 & 305800 & 305800 \tabularnewline 337 & 521 & 131728 & 175408 & & 337 & 569 & 143872 & 191584 & & 337 & 761 & 192448 & 256288 \tabularnewline 337 & 809 & 204592 & 272464 & & 337 & 857 & 216736 & 288640 & & 353 & 409 & 108472 & 144376 \tabularnewline 353 & 457 & 121192 & 161320 & & 353 & 521 & 92392 & 183912 & & 353 & 569 & 150872 & 200856 \tabularnewline 353 & 601 & 211852 & 106252 & & 353 & 761 & 201752 & 268632 & & 353 & 809 & 214472 & 285576 \tabularnewline 353 & 857 & 227192 & 302520 & & 353 & 937 & 330292 & 165556 & & 353 & 953 & 252632 & 336408 \tabularnewline 401 & 409 & 164008 & 164008 & & 401 & 457 & 183256 & 183256 & & 401 & 569 & 228168 & 228168 \tabularnewline 401 & 617 & 247416 & 185816 & & 401 & 809 & 324408 & 324408 & & 401 & 857 & 343656 & 343656 \tabularnewline 401 & 937 & 375268 & 281668 & & 401 & 953 & 382152 & 382152 & & 409 & 449 & 183640 & 183640 \tabularnewline 409 & 521 & 213088 & 213088 & & 409 & 569 & 232720 & 232720 & & 409 & 593 & 242536 & 242536 \tabularnewline 409 & 617 & 252352 & 189520 & & 409 & 641 & 262168 & 262168 & & 409 & 761 & 311248 & 311248 \tabularnewline 409 & 809 & 330880 & 330880 & & 409 & 857 & 350512 & 350512 & & 409 & 881 & 359888 & 270128 \tabularnewline 409 & 929 & 379960 & 379960 & & 409 & 977 & 399592 & 399592 & & 433 & 521 & 225592 & 225592 \tabularnewline 433 & 569 & 246376 & 246376 & & 433 & 617 & 267160 & 200632 & & 433 & 761 & 329512 & 329512 \tabularnewline 433 & 809 & 350296 & 350296 & & 433 & 857 & 371080 & 371080 & & 433 & 953 & 412648 & 412648 \tabularnewline 449 & 457 & 205192 & 205192 & & 449 & 521 & 233928 & 233928 & & 449 & 569 & 255480 & 255480 \tabularnewline 449 & 601 & 269548 & 202348 & & 449 & 761 & 341688 & 341688 & & 449 & 809 & 363240 & 363240 \tabularnewline 449 & 857 & 384792 & 384792 & & 449 & 937 & 420244 & 210580 & & 457 & 521 & 238096 & 238096 \tabularnewline 457 & 569 & 260032 & 260032 & & 457 & 593 & 271000 & 136024 & & 457 & 617 & 281968 & 211744 \tabularnewline 457 & 641 & 292936 & 292936 & & 457 & 809 & 369712 & 369712 & & 457 & 857 & 391648 & 391648 \tabularnewline 457 & 881 & 402176 & 301856 & & 457 & 929 & 424552 & 424552 & & 457 & 953 & 435520 & 435520 \tabularnewline 457 & 977 & 446488 & 446488 & & 521 & 569 & 296448 & 296448 & & 521 & 577 & 300616 & 225736 \tabularnewline 521 & 593 & 308952 & 308952 & & 521 & 617 & 321456 & 241376 & & 521 & 673 & 350632 & 350632 \tabularnewline 521 & 769 & 400648 & 400648 & & 521 & 809 & 421488 & 421488 & & 521 & 857 & 446496 & 446496 \tabularnewline 521 & 929 & 484008 & 484008 & & 521 & 953 & 496512 & 496512 & & 521 & 977 & 509016 & 509016 \tabularnewline 569 & 577 & 328312 & 164728 & & 569 & 593 & 337416 & 253352 & & 569 & 601 & 341668 & 341668 \tabularnewline 569 & 617 & 351072 & 263600 & & 569 & 641 & 364728 & 364728 & & 569 & 673 & 382936 & 382936 \tabularnewline 569 & 761 & 433008 & 433008 & & 569 & 769 & 437560 & 437560 & & 569 & 809 & 460320 & 460320 \tabularnewline 569 & 857 & 487632 & 487632 & & 569 & 881 & 500848 & 375888 & & 569 & 929 & 528600 & 528600 \tabularnewline 569 & 937 & 532684 & 399772 & & 569 & 953 & 542256 & 542256 & & 569 & 977 & 555912 & 555912 \tabularnewline 577 & 617 & 356008 & 356008 & & 577 & 761 & 439096 & 439096 & & 577 & 809 & 350440 & 466792 \tabularnewline 577 & 857 & 494488 & 494488 & & 577 & 953 & 412792 & 549880 & & 593 & 601 & 356092 & 178492 \tabularnewline 593 & 617 & 365880 & 365880 & & 593 & 761 & 451272 & 451272 & & 593 & 809 & 360152 & 479736 \tabularnewline 593 & 857 & 254824 & 508200 & & 593 & 937 & 555172 & 278116 & & 593 & 953 & 424232 & 565128 \tabularnewline 601 & 617 & 185716 & 370516 & & 601 & 809 & 485908 & 485908 & & 601 & 857 & 257956 & 514756 \tabularnewline 601 & 929 & 418828 & 558028 & & 601 & 953 & 429652 & 572452 & & 601 & 977 & 586876 & 586876 \tabularnewline 617 & 641 & 296936 & 395496 & & 617 & 761 & 235456 & 469536 & & 617 & 769 & 237928 & 474472 \tabularnewline 617 & 809 & 374720 & 499152 & & 617 & 857 & 265120 & 528768 & & 617 & 929 & 573192 & 573192 \tabularnewline 617 & 937 & 577660 & 289372 & & 617 & 977 & 452504 & 602808 & & 641 & 809 & 518568 & 518568 \tabularnewline 641 & 857 & 549336 & 549336 & & 641 & 937 & 600148 & 600148 & & 641 & 953 & 610872 & 610872 \tabularnewline 673 & 761 & 512152 & 512152 & & 673 & 809 & 544456 & 544456 & & 673 & 857 & 576760 & 576760 \tabularnewline 761 & 769 & 585208 & 585208 & & 761 & 809 & 615648 & 615648 & & 761 & 857 & 652176 & 652176 \tabularnewline 761 & 929 & 706968 & 706968 & & 761 & 937 & 712588 & 534748 & & 761 & 953 & 725232 & 725232 \tabularnewline 761 & 977 & 743496 & 743496 & & 769 & 809 & 622120 & 622120 & & 769 & 857 & 659032 & 659032 \tabularnewline 769 & 953 & 732856 & 732856 & & 809 & 857 & 693312 & 693312 & & 809 & 881 & 712288 & 356768 \tabularnewline 809 & 929 & 751560 & 751560 & & 809 & 937 & 757564 & 757564 & & 809 & 953 & 770976 & 770976 \tabularnewline 809 & 977 & 790392 & 790392 & & 857 & 881 & 754576 & 566256 & & 857 & 929 & 796152 & 796152 \tabularnewline 857 & 937 & 802540 & 602236 & & 857 & 953 & 816720 & 816720 & & 857 & 977 & 837288 & 837288 \tabularnewline 881 & 937 & 412748 & 412748 & & 881 & 953 & 420272 & 839152 & & 929 & 937 & 870004 & 870004 \tabularnewline 929 & 953 & 885336 & 885336 & & 937 & 953 & 446956 & 892492 & & 937 & 977 & 686596 & 914980 \tabularnewline 953 & 977 & 931080 & 931080 & & & & & & & & & & \tabularnewline
D = 500; i = 0
for p in prime_range(D):
    for q in prime_range(p,D):
        if gcd(p-1,q-1) != 8: continue
        Lpq = L(p,q); Lqp = L(q,p)
        g = int(GF(p).multiplicative_generator().crt(GF(q).multiplicative_generator()))
        if LC(p,q,g) != Lpq: print ("Wrong for p = %s, q = %s, g = %s, LC(p,q,g) = %s, L(p,q) = %s" % (p,q,g,LC(p,q,g),Lpq))
        if LC(q,p,g) != Lqp: print ("Wrong for p = %s, q = %s, g = %s, LC(p,q,g) = %s, L(p,q) = %s" % (q,p,g,LC(q,p,g),Lqp))
        print ("p = %3s  q = %3s  g = %6s  LC(p,q,g) = L(p,q) = %6s  LC(q,p,g) = L(q,p) = %6s" % (p,q,g,Lpq,Lqp))
        i += 1
print i
p = 17 q = 41 g = 88 LC(p,q,g) = L(p,q) = 696 LC(q,p,g) = L(q,p) = 696 p = 17 q = 73 g = 224 LC(p,q,g) = L(p,q) = 1204 LC(q,p,g) = L(q,p) = 916 p = 17 q = 89 g = 3 LC(p,q,g) = L(p,q) = 1468 LC(q,p,g) = L(q,p) = 764 p = 17 q = 137 g = 3 LC(p,q,g) = L(p,q) = 2328 LC(q,p,g) = L(q,p) = 2328 p = 17 q = 233 g = 3 LC(p,q,g) = L(p,q) = 3844 LC(q,p,g) = L(q,p) = 2916 p = 17 q = 281 g = 3 LC(p,q,g) = L(p,q) = 4776 LC(q,p,g) = L(q,p) = 2536 p = 17 q = 313 g = 5018 LC(p,q,g) = L(p,q) = 5320 LC(q,p,g) = L(q,p) = 5320 p = 17 q = 409 g = 6565 LC(p,q,g) = L(p,q) = 6952 LC(q,p,g) = L(q,p) = 6952 p = 17 q = 457 g = 2298 LC(p,q,g) = L(p,q) = 7768 LC(q,p,g) = L(q,p) = 7768 p = 41 q = 73 g = 662 LC(p,q,g) = L(p,q) = 2956 LC(q,p,g) = L(q,p) = 2956 p = 41 q = 89 g = 1605 LC(p,q,g) = L(p,q) = 3604 LC(q,p,g) = L(q,p) = 2724 p = 41 q = 97 g = 1072 LC(p,q,g) = L(p,q) = 3976 LC(q,p,g) = L(q,p) = 3976 p = 41 q = 113 g = 1359 LC(p,q,g) = L(p,q) = 4632 LC(q,p,g) = L(q,p) = 4632 p = 41 q = 137 g = 1236 LC(p,q,g) = L(p,q) = 5616 LC(q,p,g) = L(q,p) = 5616 p = 41 q = 193 g = 3286 LC(p,q,g) = L(p,q) = 7912 LC(q,p,g) = L(q,p) = 7912 p = 41 q = 233 g = 5828 LC(p,q,g) = L(p,q) = 9436 LC(q,p,g) = L(q,p) = 7116 p = 41 q = 257 g = 1031 LC(p,q,g) = L(p,q) = 10408 LC(q,p,g) = L(q,p) = 7848 p = 41 q = 313 g = 949 LC(p,q,g) = L(p,q) = 12832 LC(q,p,g) = L(q,p) = 12832 p = 41 q = 337 g = 12142 LC(p,q,g) = L(p,q) = 13648 LC(q,p,g) = L(q,p) = 13648 p = 41 q = 353 g = 9887 LC(p,q,g) = L(p,q) = 14472 LC(q,p,g) = L(q,p) = 14472 p = 41 q = 409 g = 6156 LC(p,q,g) = L(p,q) = 16768 LC(q,p,g) = L(q,p) = 16768 p = 41 q = 433 g = 10830 LC(p,q,g) = L(p,q) = 17752 LC(q,p,g) = L(q,p) = 17752 p = 41 q = 449 g = 8534 LC(p,q,g) = L(p,q) = 18408 LC(q,p,g) = L(q,p) = 18408 p = 41 q = 457 g = 15094 LC(p,q,g) = L(p,q) = 18736 LC(q,p,g) = L(q,p) = 18736 p = 73 q = 89 g = 5699 LC(p,q,g) = L(p,q) = 3248 LC(q,p,g) = L(q,p) = 3248 p = 73 q = 113 g = 1246 LC(p,q,g) = L(p,q) = 4180 LC(q,p,g) = L(q,p) = 8212 p = 73 q = 137 g = 2195 LC(p,q,g) = L(p,q) = 5068 LC(q,p,g) = L(q,p) = 9964 p = 73 q = 233 g = 4896 LC(p,q,g) = L(p,q) = 8504 LC(q,p,g) = L(q,p) = 8504 p = 73 q = 257 g = 12853 LC(p,q,g) = L(p,q) = 9380 LC(q,p,g) = L(q,p) = 9380 p = 73 q = 281 g = 9276 LC(p,q,g) = L(p,q) = 10396 LC(q,p,g) = L(q,p) = 20476 p = 73 q = 353 g = 4239 LC(p,q,g) = L(p,q) = 13060 LC(q,p,g) = L(q,p) = 25732 p = 73 q = 401 g = 27672 LC(p,q,g) = L(p,q) = 29236 LC(q,p,g) = L(q,p) = 29236 p = 73 q = 449 g = 17963 LC(p,q,g) = L(p,q) = 24676 LC(q,p,g) = L(q,p) = 32740 p = 89 q = 97 g = 2139 LC(p,q,g) = L(p,q) = 8588 LC(q,p,g) = L(q,p) = 8588 p = 89 q = 113 g = 3 LC(p,q,g) = L(p,q) = 5084 LC(q,p,g) = L(q,p) = 10012 p = 89 q = 137 g = 3 LC(p,q,g) = L(p,q) = 9156 LC(q,p,g) = L(q,p) = 12148 p = 89 q = 193 g = 14866 LC(p,q,g) = L(p,q) = 12908 LC(q,p,g) = L(q,p) = 17132 p = 89 q = 233 g = 3 LC(p,q,g) = L(p,q) = 10368 LC(q,p,g) = L(q,p) = 10368 p = 89 q = 241 g = 1694 LC(p,q,g) = L(p,q) = 16124 LC(q,p,g) = L(q,p) = 21404 p = 89 q = 257 g = 3 LC(p,q,g) = L(p,q) = 11436 LC(q,p,g) = L(q,p) = 11436 p = 89 q = 281 g = 3 LC(p,q,g) = L(p,q) = 12644 LC(q,p,g) = L(q,p) = 24964 p = 89 q = 313 g = 7835 LC(p,q,g) = L(p,q) = 20948 LC(q,p,g) = L(q,p) = 27812 p = 89 q = 337 g = 26970 LC(p,q,g) = L(p,q) = 14996 LC(q,p,g) = L(q,p) = 14996 p = 89 q = 401 g = 3 LC(p,q,g) = L(p,q) = 35644 LC(q,p,g) = L(q,p) = 35644 p = 89 q = 409 g = 18426 LC(p,q,g) = L(p,q) = 18404 LC(q,p,g) = L(q,p) = 36356 p = 89 q = 433 g = 6500 LC(p,q,g) = L(p,q) = 28988 LC(q,p,g) = L(q,p) = 38492 p = 89 q = 449 g = 3 LC(p,q,g) = L(p,q) = 20204 LC(q,p,g) = L(q,p) = 39916 p = 89 q = 457 g = 6411 LC(p,q,g) = L(p,q) = 30596 LC(q,p,g) = L(q,p) = 40628 p = 97 q = 137 g = 4661 LC(p,q,g) = L(p,q) = 13288 LC(q,p,g) = L(q,p) = 13288 p = 97 q = 233 g = 2333 LC(p,q,g) = L(p,q) = 22484 LC(q,p,g) = L(q,p) = 16916 p = 97 q = 281 g = 16301 LC(p,q,g) = L(p,q) = 27256 LC(q,p,g) = L(q,p) = 20536 p = 113 q = 137 g = 3 LC(p,q,g) = L(p,q) = 11672 LC(q,p,g) = L(q,p) = 15480 p = 113 q = 233 g = 3 LC(p,q,g) = L(p,q) = 26212 LC(q,p,g) = L(q,p) = 13220 p = 113 q = 313 g = 6896 LC(p,q,g) = L(p,q) = 35368 LC(q,p,g) = L(q,p) = 35368 p = 113 q = 409 g = 30287 LC(p,q,g) = L(p,q) = 34792 LC(q,p,g) = L(q,p) = 46216 p = 113 q = 457 g = 50740 LC(p,q,g) = L(p,q) = 38872 LC(q,p,g) = L(q,p) = 51640 p = 137 q = 193 g = 8497 LC(p,q,g) = L(p,q) = 26440 LC(q,p,g) = L(q,p) = 26440 p = 137 q = 233 g = 3 LC(p,q,g) = L(p,q) = 31804 LC(q,p,g) = L(q,p) = 23916 p = 137 q = 241 g = 19046 LC(p,q,g) = L(p,q) = 33016 LC(q,p,g) = L(q,p) = 33016 p = 137 q = 257 g = 3 LC(p,q,g) = L(p,q) = 35080 LC(q,p,g) = L(q,p) = 35080 p = 137 q = 281 g = 3 LC(p,q,g) = L(p,q) = 38496 LC(q,p,g) = L(q,p) = 19456 p = 137 q = 313 g = 15347 LC(p,q,g) = L(p,q) = 42880 LC(q,p,g) = L(q,p) = 42880 p = 137 q = 337 g = 25622 LC(p,q,g) = L(p,q) = 46000 LC(q,p,g) = L(q,p) = 23152 p = 137 q = 353 g = 3 LC(p,q,g) = L(p,q) = 48360 LC(q,p,g) = L(q,p) = 36392 p = 137 q = 401 g = 3 LC(p,q,g) = L(p,q) = 54936 LC(q,p,g) = L(q,p) = 54936 p = 137 q = 433 g = 48501 LC(p,q,g) = L(p,q) = 59320 LC(q,p,g) = L(q,p) = 59320 p = 137 q = 449 g = 3 LC(p,q,g) = L(p,q) = 61512 LC(q,p,g) = L(q,p) = 61512 p = 137 q = 457 g = 48912 LC(p,q,g) = L(p,q) = 62608 LC(q,p,g) = L(q,p) = 62608 p = 193 q = 233 g = 6760 LC(p,q,g) = L(p,q) = 44852 LC(q,p,g) = L(q,p) = 33716 p = 193 q = 281 g = 38219 LC(p,q,g) = L(p,q) = 54232 LC(q,p,g) = L(q,p) = 40792 p = 233 q = 241 g = 27963 LC(p,q,g) = L(p,q) = 56036 LC(q,p,g) = L(q,p) = 56036 p = 233 q = 257 g = 3 LC(p,q,g) = L(p,q) = 29940 LC(q,p,g) = L(q,p) = 29940 p = 233 q = 281 g = 3 LC(p,q,g) = L(p,q) = 32876 LC(q,p,g) = L(q,p) = 65356 p = 233 q = 313 g = 72000 LC(p,q,g) = L(p,q) = 54716 LC(q,p,g) = L(q,p) = 72812 p = 233 q = 337 g = 53593 LC(p,q,g) = L(p,q) = 39260 LC(q,p,g) = L(q,p) = 39260 p = 233 q = 353 g = 3 LC(p,q,g) = L(p,q) = 41300 LC(q,p,g) = L(q,p) = 82132 p = 233 q = 401 g = 3 LC(p,q,g) = L(p,q) = 70116 LC(q,p,g) = L(q,p) = 93316 p = 233 q = 409 g = 70369 LC(p,q,g) = L(p,q) = 71516 LC(q,p,g) = L(q,p) = 95180 p = 233 q = 433 g = 97863 LC(p,q,g) = L(p,q) = 50660 LC(q,p,g) = L(q,p) = 100772 p = 233 q = 449 g = 3 LC(p,q,g) = L(p,q) = 78516 LC(q,p,g) = L(q,p) = 104500 p = 233 q = 457 g = 12352 LC(p,q,g) = L(p,q) = 106364 LC(q,p,g) = L(q,p) = 106364 p = 257 q = 281 g = 3 LC(p,q,g) = L(p,q) = 36248 LC(q,p,g) = L(q,p) = 72088 p = 257 q = 313 g = 10026 LC(p,q,g) = L(p,q) = 60344 LC(q,p,g) = L(q,p) = 80312 p = 257 q = 409 g = 51146 LC(p,q,g) = L(p,q) = 78872 LC(q,p,g) = L(q,p) = 104984 p = 257 q = 457 g = 76332 LC(p,q,g) = L(p,q) = 58952 LC(q,p,g) = L(q,p) = 117320 p = 281 q = 313 g = 85146 LC(p,q,g) = L(p,q) = 44272 LC(q,p,g) = L(q,p) = 87952 p = 281 q = 353 g = 3 LC(p,q,g) = L(p,q) = 99192 LC(q,p,g) = L(q,p) = 99192 p = 281 q = 409 g = 87956 LC(p,q,g) = L(p,q) = 57808 LC(q,p,g) = L(q,p) = 114928 p = 281 q = 433 g = 52831 LC(p,q,g) = L(p,q) = 91432 LC(q,p,g) = L(q,p) = 121672 p = 281 q = 457 g = 30632 LC(p,q,g) = L(p,q) = 96496 LC(q,p,g) = L(q,p) = 128416 p = 313 q = 353 g = 2827 LC(p,q,g) = L(p,q) = 110488 LC(q,p,g) = L(q,p) = 83032 p = 313 q = 401 g = 35692 LC(p,q,g) = L(p,q) = 125512 LC(q,p,g) = L(q,p) = 125512 p = 313 q = 449 g = 34127 LC(p,q,g) = L(p,q) = 140536 LC(q,p,g) = L(q,p) = 140536 p = 353 q = 409 g = 87547 LC(p,q,g) = L(p,q) = 108472 LC(q,p,g) = L(q,p) = 144376 p = 353 q = 457 g = 27890 LC(p,q,g) = L(p,q) = 121192 LC(q,p,g) = L(q,p) = 161320 p = 401 q = 409 g = 40103 LC(p,q,g) = L(p,q) = 164008 LC(q,p,g) = L(q,p) = 164008 p = 401 q = 457 g = 85015 LC(p,q,g) = L(p,q) = 183256 LC(q,p,g) = L(q,p) = 183256 p = 409 q = 449 g = 174664 LC(p,q,g) = L(p,q) = 183640 LC(q,p,g) = L(q,p) = 183640 p = 449 q = 457 g = 50740 LC(p,q,g) = L(p,q) = 205192 LC(q,p,g) = L(q,p) = 205192 99

p = 17 q = 41 g = 54 L(p,q) = 696 L(q,p) = 696 p = 17 q = 73 g = 31 L(p,q) = 1204 L(q,p) = 916 p = 17 q = 89 g = 82 L(p,q) = 1468 L(q,p) = 764 p = 41 q = 73 g = 26 L(p,q) = 2956 L(q,p) = 2956 p = 41 q = 89 g = 54 L(p,q) = 3604 L(q,p) = 2724 p = 41 q = 97 g = 26 L(p,q) = 3976 L(q,p) = 3976 p = 73 q = 89 g = 86 L(p,q) = 3248 L(q,p) = 3248 p = 89 q = 97 g = 29 L(p,q) = 8588 L(q,p) = 8588
D = 1000
for p in prime_range(D):
    for q in prime_range(p,D):
        if gcd(p-1,q-1) != 8: continue
        Ltpq = Lthm(p,q); Ltqp = Lthm(q,p)
        #for g in range(1,p*q):
            #if mod(g,p).is_primitive_root() and mod(g,q).is_primitive_root():
                #if Lpol(p,q,g) != Ltpq: print ("Theorem wrong for p = %s, q = %s, g = %s, Lpol = %s, Lthm = %s" % (p,q,g,Lpol(p,q,g),Ltpq))
                #if Lpol(q,p,g) != Ltqp: print ("Theorem wrong for p = %s, q = %s, g = %s, Lpol = %s, Lthm = %s" % (q,p,g,Lpol(q,p,g),Ltqp))
        print ("p = %s  q = %s  L(p,q) = %s  L(q,p) = %s" % (p,q,Ltpq,Ltqp))