cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

This page as a plain text file.
%I A298940 #51 Feb 07 2018 02:43:10
%S A298940 1,3,10,39,60,121,0,117,4920,0,0,0,28322,0,1434890,0,0,0,116226146,0,
%T A298940 0,15690529803,0,108443565,66891206007,0,0,0,0,0,0,0,0,0,0,0,
%U A298940 22514195294549868,0,405255515301897626,0,1823649818858539320,0,0,5861731560616733529,0,0,0
%N 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.
%C A298940 3^n - 2 divides 3^(n + (2m + 1) * a(n)) + 2 for all nonnegative integers m.
%C A298940 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 A298940 Robert Israel, <a href="/A298940/b298940.txt">Table of n, a(n) for n = 1..166</a>
%e A298940 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 A298940 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 A298940 # This requires Maple 2016 or later
%p A298940 f:= proc(n) local m,ps,a,p,q,phiq,v,br,ar;
%p A298940   m:= 3^n-2;
%p A298940    ps:= ifactors(m)[2];
%p A298940    a:= 0;
%p A298940    for p in ps do
%p A298940      q:= p[1]^p[2];
%p A298940      phiq:= (p[1]-1)*p[1]^(p[2]-1);
%p A298940      v:= NumberTheory:-MultiplicativeOrder(3,q);
%p A298940      if v::odd then return 0 fi;
%p A298940      if p[2]=1 then br:= v/2
%p A298940      else br:= traperror(NumberTheory:-ModularLog(-1,3,q));
%p A298940           if br = lasterror then return 0 fi;
%p A298940      fi;
%p A298940      if a = 0 then a:= v; ar:= br
%p A298940      else
%p A298940         ar:= NumberTheory:-ChineseRemainder([ar,br],[a,v]);
%p A298940         if ar = FAIL then return 0 fi;
%p A298940         a:= ilcm(a, v);
%p A298940      fi
%p A298940    od:
%p A298940    ar;
%p A298940 end proc:
%p A298940 f(1):= 1:
%p A298940 map(f, [$1..50]); # _Robert Israel_, Feb 06 2018
%t A298940 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 A298940 (Python)
%o A298940 from sympy import discrete_log
%o A298940 def A298940(n):
%o A298940     if n == 1:
%o A298940         return 1
%o A298940     try:
%o A298940         return discrete_log(3**n-2,-1,3)
%o A298940     except ValueError:
%o A298940         return 0 # _Chai Wah Wu_, Feb 05 2018
%o A298940 (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 A298940 Cf. A168607, A298827.
%K A298940 nonn
%O A298940 1,2
%A A298940 _Luke W. Richards_, Jan 29 2018
%E A298940 Corrected by _Robert Israel_, Feb 05 2018