The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A298940 a(n) is the smallest positive integer k such that 3^n - 2 divides 3^(n + k) + 2, or 0 if there is no such k. 1

%I #51 Feb 07 2018 02:43:10

%S 1,3,10,39,60,121,0,117,4920,0,0,0,28322,0,1434890,0,0,0,116226146,0,

%T 0,15690529803,0,108443565,66891206007,0,0,0,0,0,0,0,0,0,0,0,

%U 22514195294549868,0,405255515301897626,0,1823649818858539320,0,0,5861731560616733529,0,0,0

%N a(n) is the smallest positive integer k such that 3^n - 2 divides 3^(n + k) + 2, or 0 if there is no such k.

%C 3^n - 2 divides 3^(n + (2m + 1) * a(n)) + 2 for all nonnegative integers m.

%C a(n) is the least positive integer k, if any, such that 3^k == -1 (mod 3^n-2). If the order of 3 mod p is odd for some prime p dividing 3^n-2, a(n)=0. - _Robert Israel_, Feb 05 2018

%H Robert Israel, <a href="/A298940/b298940.txt">Table of n, a(n) for n = 1..166</a>

%e a(2) = 3 because 3^2 - 2 divides 3^5 + 2 and 3^2 - 2 does not divide any 3^x - 2 for 2 < x < 5.

%e a(5) = 60 because 3^5 - 2 divides 3^65 + 2 and 3^5 - 2 does not divide any 3^x - 2 for 5 < x < 65.

%p # This requires Maple 2016 or later

%p f:= proc(n) local m,ps,a,p,q,phiq,v,br,ar;

%p m:= 3^n-2;

%p ps:= ifactors(m)[2];

%p a:= 0;

%p for p in ps do

%p q:= p[1]^p[2];

%p phiq:= (p[1]-1)*p[1]^(p[2]-1);

%p v:= NumberTheory:-MultiplicativeOrder(3,q);

%p if v::odd then return 0 fi;

%p if p[2]=1 then br:= v/2

%p else br:= traperror(NumberTheory:-ModularLog(-1,3,q));

%p if br = lasterror then return 0 fi;

%p fi;

%p if a = 0 then a:= v; ar:= br

%p else

%p ar:= NumberTheory:-ChineseRemainder([ar,br],[a,v]);

%p if ar = FAIL then return 0 fi;

%p a:= ilcm(a, v);

%p fi

%p od:

%p ar;

%p end proc:

%p f(1):= 1:

%p map(f, [$1..50]); # _Robert Israel_, Feb 06 2018

%t a[1] = 1; a[n_] := If[IntegerQ[order = MultiplicativeOrder[3, 3^n - 2, {-1}]], order, 0]; Table[an = a[n]; Print["a(", n, ") = ", an]; an, {n, 1, 20}] (* _Jean-François Alcover_, Feb 06 2018, after _Robert Israel_ *)

%o (Python)

%o from sympy import discrete_log

%o def A298940(n):

%o if n == 1:

%o return 1

%o try:

%o return discrete_log(3**n-2,-1,3)

%o except ValueError:

%o return 0 # _Chai Wah Wu_, Feb 05 2018

%o (PARI) a(n) = if(n==1, return(1)); my(l = znlog(-1, Mod(3, 3^n - 2))); if(l == [], return(0), return(l)) \\ _Iain Fox_, Feb 06 2018

%Y Cf. A168607, A298827.

%K nonn

%O 1,2

%A _Luke W. Richards_, Jan 29 2018

%E Corrected by _Robert Israel_, Feb 05 2018

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified June 9 02:41 EDT 2024. Contains 373227 sequences. (Running on oeis4.)