mersenneforum.org  

Go Back   mersenneforum.org > Great Internet Mersenne Prime Search > Math

Reply
 
Thread Tools
Old 2018-06-17, 05:06   #1
devarajkandadai
 
devarajkandadai's Avatar
 
May 2004

22×79 Posts
Default 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?
devarajkandadai is offline   Reply With Quote
Old 2018-06-18, 10:37   #2
LaurV
Romulan Interpreter
 
LaurV's Avatar
 
Jun 2011
Thailand

961110 Posts
Default

Quote:
Originally Posted by devarajkandadai View Post
Is there s shorter cut?
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 )

Last fiddled with by LaurV on 2018-06-18 at 10:39
LaurV is offline   Reply With Quote
Old 2018-06-18, 11:01   #3
axn
 
axn's Avatar
 
Jun 2003

116738 Posts
Default

znlog(2, Mod(3, 13))
axn is offline   Reply With Quote
Old 2018-06-18, 17:17   #4
Dr Sardonicus
 
Dr Sardonicus's Avatar
 
Feb 2017
Nowhere

4,643 Posts
Default

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 is offline   Reply With Quote
Old 2018-06-18, 22:46   #5
Dr Sardonicus
 
Dr Sardonicus's Avatar
 
Feb 2017
Nowhere

4,643 Posts
Default

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


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).
Dr Sardonicus is offline   Reply With Quote
Old 2018-06-19, 03:06   #6
axn
 
axn's Avatar
 
Jun 2003

5,051 Posts
Default

Quote:
Originally Posted by Dr Sardonicus View Post
I done screwed up. That'll teach me to think before I post


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).
Is this correct for p>=5?
Code:
isimpossible(p)=Mod(2,p)^znorder(Mod(3,p))!=1
axn is offline   Reply With Quote
Old 2018-06-19, 05:12   #7
devarajkandadai
 
devarajkandadai's Avatar
 
May 2004

22×79 Posts
Default Pari/OEIS A123239

Quote:
Originally Posted by LaurV View Post
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 )
Thank you and Dr. Sardonicus;will try
devarajkandadai is offline   Reply With Quote
Old 2018-06-19, 13:09   #8
Dr Sardonicus
 
Dr Sardonicus's Avatar
 
Feb 2017
Nowhere

4,643 Posts
Default

Quote:
Originally Posted by axn View Post
Is this correct for p>=5?
Code:
isimpossible(p)=Mod(2,p)^znorder(Mod(3,p))!=1
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]

Last fiddled with by Dr Sardonicus on 2018-06-19 at 13:20 Reason: Adding stuff
Dr Sardonicus is offline   Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
LLL in GP/Pari paul0 Programming 2 2015-11-17 13:04
PARI vs GAP skan Miscellaneous Math 0 2012-12-16 00:13
pari devarajkandadai Programming 21 2012-08-31 18:08
Pari/GP in Linux CRGreathouse Software 15 2009-03-22 14:03
64-bit Pari? CRGreathouse Software 2 2009-03-13 04:22

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


Fri Jul 16 18:44:00 UTC 2021 up 49 days, 16:31, 1 user, load averages: 5.48, 5.41, 4.80

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

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.