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.

Original entry on oeis.org

1, 3, 10, 39, 60, 121, 0, 117, 4920, 0, 0, 0, 28322, 0, 1434890, 0, 0, 0, 116226146, 0, 0, 15690529803, 0, 108443565, 66891206007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22514195294549868, 0, 405255515301897626, 0, 1823649818858539320, 0, 0, 5861731560616733529, 0, 0, 0
Offset: 1

Views

Author

Luke W. Richards, Jan 29 2018

Keywords

Comments

3^n - 2 divides 3^(n + (2m + 1) * a(n)) + 2 for all nonnegative integers m.
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

Examples

			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.
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.
		

Crossrefs

Programs

  • Maple
    # This requires Maple 2016 or later
    f:= proc(n) local m,ps,a,p,q,phiq,v,br,ar;
      m:= 3^n-2;
       ps:= ifactors(m)[2];
       a:= 0;
       for p in ps do
         q:= p[1]^p[2];
         phiq:= (p[1]-1)*p[1]^(p[2]-1);
         v:= NumberTheory:-MultiplicativeOrder(3,q);
         if v::odd then return 0 fi;
         if p[2]=1 then br:= v/2
         else br:= traperror(NumberTheory:-ModularLog(-1,3,q));
              if br = lasterror then return 0 fi;
         fi;
         if a = 0 then a:= v; ar:= br
         else
            ar:= NumberTheory:-ChineseRemainder([ar,br],[a,v]);
            if ar = FAIL then return 0 fi;
            a:= ilcm(a, v);
         fi
       od:
       ar;
    end proc:
    f(1):= 1:
    map(f, [$1..50]); # Robert Israel, Feb 06 2018
  • Mathematica
    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 *)
  • 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
  • Python
    from sympy import discrete_log
    def A298940(n):
        if n == 1:
            return 1
        try:
            return discrete_log(3**n-2,-1,3)
        except ValueError:
            return 0 # Chai Wah Wu, Feb 05 2018
    

Extensions

Corrected by Robert Israel, Feb 05 2018