mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   Math (https://www.mersenneforum.org/forumdisplay.php?f=8)
-   -   Pari/A123239 (https://www.mersenneforum.org/showthread.php?t=23452)

devarajkandadai 2018-06-17 05:06

Pari/A123239
 
This sequence: impossible prime factors of (3^n-2).In pari to test whether 13 is an impossible prime factor of (3^n-2) my code: {is(n)=Mod(3^13)^n==2}; for(n=1,12,print(is(n))).
Is there s shorter cut?

LaurV 2018-06-18 10:37

[QUOTE=devarajkandadai;489978]Is there s shorter cut?[/QUOTE]
yes, you will only need to test for 3^2 (mod 13), and 3^3 (mod 13) and because this is 1, stop.
(And better use Mod(3,13) instead of the incorrect Mod(3^13), hehe, yeah, I know that is a typo :razz:)

axn 2018-06-18 11:01

[c]znlog(2, Mod(3, 13))[/c]

Dr Sardonicus 2018-06-18 17:17

If 3 is a quadratic residue (mod p) but 2 is a quadratic non-residue (mod p), then 3^n == 2 (mod p) is impossible. This situation is characterized by the linear congruences

p == 11 or 13 (mod 24).

Let q > 2 be a prime. Then as with quadratic residues, we can say, for p == 1 (mod q),

If 3 is a q-th power residue (mod p) but 2 is not a q-th power residue (mod p), then 3^n == 2 (mod p) is impossible.

Unfortunately, this situation is not characterized by linear congruences. One can test for the condition, for p == 1 (mod q),

3^(p-1)/q == 1 (mod p) but 3^(p-1)/q !== 1 (mod p).

Checking for q = 2, 3, 5, and 7 gives the following pairs [p, q] of disqualified primes p < 1000, with the smallest q disqualifying each.

[[11, 2], [13, 2], [37, 2], [41, 5], [59, 2], [61, 2], [67, 3], [73, 3], [83, 2], [103, 3], [107, 2], [109, 2], [131, 2], [151, 3], [157, 2], [179, 2], [181, 2], [193, 3], [227, 2], [229, 2], [251, 2], [271, 3], [277, 2], [347, 2], [349, 2], [367, 3], [373, 2], [397, 2], [419, 2], [421, 2], [431, 5], [443, 2], [467, 2], [491, 2], [523, 3], [541, 2], [547, 3], [563, 2], [577, 3], [587, 2], [613, 2], [619, 3], [659, 2], [661, 2], [683, 2], [709, 2], [733, 2], [757, 2], [761, 5], [787, 3], [827, 2], [829, 2], [853, 2], [877, 2], [883, 7], [947, 2], [967, 3], [971, 2], [991, 3], [997, 2]]

Dr Sardonicus 2018-06-18 22:46

I done screwed up. That'll teach me to think before I post
:missingteeth:

Obviously, for p > 3, the condition that p divide 3^n - 2 for some n, is that the multiplicative order of 2 (mod p) divide the multiplicative order of 3 (mod p). And, this can happen even if 2 and 3 are both q-th power residues (mod p) for some prime divisor q of p - 1.

Examples are p = 193 (q = 2); 307 (q = 3) and 313 (q = 2).

axn 2018-06-19 03:06

[QUOTE=Dr Sardonicus;490089]I done screwed up. That'll teach me to think before I post
:missingteeth:

Obviously, for p > 3, the condition that p divide 3^n - 2 for some n, is that the multiplicative order of 2 (mod p) divide the multiplicative order of 3 (mod p). And, this can happen even if 2 and 3 are both q-th power residues (mod p) for some prime divisor q of p - 1.

Examples are p = 193 (q = 2); 307 (q = 3) and 313 (q = 2).[/QUOTE]

Is this correct for p>=5?
[CODE]isimpossible(p)=Mod(2,p)^znorder(Mod(3,p))!=1[/CODE]

devarajkandadai 2018-06-19 05:12

Pari/OEIS A123239
 
[QUOTE=LaurV;490051]yes, you will only need to test for 3^2 (mod 13), and 3^3 (mod 13) and because this is 1, stop.
(And better use Mod(3,13) instead of the incorrect Mod(3^13), hehe, yeah, I know that is a typo :razz:)[/QUOTE]
Thank you and Dr. Sardonicus;will try

Dr Sardonicus 2018-06-19 13:09

[QUOTE=axn;490095]Is this correct for p>=5?
[CODE]isimpossible(p)=Mod(2,p)^znorder(Mod(3,p))!=1[/CODE][/QUOTE]

Looks good to me!

EDIT: It occurred to me to count how often each of several possible relations between the multipilcative orders occurred. I don't know what is suspected along these lines...
[code]? c1=0;c2=0;c3=0;c4=0;forprime(p=5,10000000,n1=znorder(Mod(3,p));n2=znorder(Mod(2,p));if(n1!=n2&&n1%n2==0,c1++);if(n1!=n2&&n2%n1==0,c2++);if(n1%n2!=0&&n2%n1!=0,c3++);if(n1==n2,c4++));print([c1,c2,c3,c4])
[195328, 195135, 86169, 187945][/code]


All times are UTC. The time now is 18:43.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.