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.

User: Luke W. Richards

Luke W. Richards's wiki page.

Luke W. Richards has authored 10 sequences.

A307070 a(n) is the number of decimal places before the decimal expansion of 1/n terminates, or the period of the recurring portion of 1/n if it is recurring.

Original entry on oeis.org

0, 1, 1, 2, 1, 1, 6, 3, 1, 1, 2, 1, 6, 6, 1, 4, 16, 1, 18, 2, 6, 2, 22, 1, 2, 6, 3, 6, 28, 1, 15, 5, 2, 16, 6, 1, 3, 18, 6, 3, 5, 6, 21, 2, 1, 22, 46, 1, 42, 2, 16, 6, 13, 3, 2, 6, 18, 28, 58, 1, 60, 15, 6, 6, 6, 2, 33, 16, 22, 6, 35, 1, 8, 3, 1, 18, 6, 6, 13
Offset: 1

Author

Luke W. Richards, Mar 22 2019

Keywords

Comments

If the decimal expansion of 1/n terminates, we will write it as ending with infinitely many 0's (rather than 9's). Then for any n > 1, the expansion of 1/n consists of a preamble whose length is given by A051628(n), followed by a periodic part with period length A007732(n). This sequence is defined as follows: If the only primes dividing n are 2 and 5 (see A003592), a(n) = A051628(n), otherwise a(n) = A007732(n) (and the preamble is ignored). - N. J. A. Sloane, Mar 22 2019
This sequence was discovered by a school class (aged 12-13) at Arden School, Solihull, UK.
Equally space the digits 0-9 on a circle. The digits of the decimal expansion of rational numbers can be connected on this circle to form data visualizations. This sequence is useful, cf. A007732 or A051626, for identifying the complexity of that visualization.

Examples

			1/1 is 1.0. There are no decimal digits, so a(1) = 0.
1/2 is 0.5. This is a terminating decimal. There is 1 digit, so a(2) = 1.
1/6 is 0.166666... This is a recurring decimal with a period of 1 (the initial '1' does not recur) so a(6) = 1.
1/7 is 0.142857142857... This is a recurring decimal, with a period of 6 ('142857') so a(7) = 6.
		

Crossrefs

See A114205 and A051628 for the preamble, A036275 and A051626 for the periodic part.

Programs

  • PARI
    a(n) = my (t=valuation(n,2), f=valuation(n,5), r=n/(2^t*5^f)); if (r==1, max(t,f), znorder(Mod(10, r))) \\ Rémy Sigrist, May 08 2019
  • Python
    def sequence(n):
      count = 0
      dividend = 1
      remainder = dividend % n
      remainders = [remainder]
      no_recurrence = True
      while remainder != 0:
        count += 1
        dividend = remainder * 10
        remainder = dividend % n
        if remainder in remainders:
          if no_recurrence:
            no_recurrence = False
            remainders = [remainder]
          else:
            return len(remainders)
        else:
          remainders.append(remainder)
      else:
        return count
    

Extensions

More terms from Rémy Sigrist, May 08 2019

A301917 a(n) is the least k for which A301916(n) divides 3^k + 1.

Original entry on oeis.org

1, 2, 3, 8, 9, 14, 15, 9, 4, 21, 26, 5, 11, 6, 39, 44, 24, 50, 17, 56, 63, 68, 69, 74, 25, 39, 81, 86, 8, 98, 99, 105, 111, 116, 60, 128, 134, 15, 140, 141, 146, 17, 158, 165, 84, 87, 176, 61, 93, 189, 194, 99, 200, 102, 73, 224, 114, 230, 231, 243, 83, 254
Offset: 1

Author

Luke W. Richards, Mar 28 2018

Keywords

Comments

This can be used to factor P-1 values for potential primes, P of the form 3^k+2.
A301915 can be used in conjunction with this sequence such that A301916 always divides 3^(a(n) + k*A301915(n)) + 1 for all nonnegative values of k.

Examples

			A301916(1) = 2 and the first value of k for which 3^k+1 is a multiple of 2 is k = 1, so a(1) = 1.
A301916(5) = 19 and the first value of k for which 3^k+1 is a multiple of 19 is k = 9, so a(5) = 9.
		

Crossrefs

Programs

  • Maple
    f:= proc(p) local t; t:= numtheory:-order(3,p); if t::even then t/2 else NULL fi end proc:
    f(2):= 1:
    map(f, [seq(ithprime(i),i=1..300)]); # Robert Israel, May 23 2018
  • Mathematica
    f[p_] := Module[{t = MultiplicativeOrder[3, p]}, If[EvenQ[t],  t/2, Nothing]];
    f[2] = 1;
    f /@ Table[Prime[i], {i, 1, 300}] (* Jean-François Alcover, Feb 02 2023, after Robert Israel *)
  • PARI
    lista(nn) = {for (n=1, nn, p = prime(n); if (p != 3, m = Mod(3, p); nb = znorder(m); for (k=1, nb, if (m^k == Mod(-1, p), print1(k, ", ")););););} \\ Michel Marcus, May 18 2018

Formula

a(n) = A301919(n+1) - 1 for n > 1.

A301916 Primes which divide numbers of the form 3^k + 1.

Original entry on oeis.org

2, 5, 7, 17, 19, 29, 31, 37, 41, 43, 53, 61, 67, 73, 79, 89, 97, 101, 103, 113, 127, 137, 139, 149, 151, 157, 163, 173, 193, 197, 199, 211, 223, 233, 241, 257, 269, 271, 281, 283, 293, 307, 317, 331, 337, 349, 353, 367, 373, 379, 389, 397, 401, 409, 439
Offset: 1

Author

Luke W. Richards, Mar 28 2018

Keywords

Comments

This sequence can be used to factor P-1 values for prime candidates of the form 3^k+2, to aid with primality testing.
a(1) = 2 divides every number of the form 3^k+1. It is the only term with this property.
For k > 2, A000040(k) is a member if and only if A062117(k) is even. - Robert Israel, May 23 2018

Examples

			Every value of 3^k+1 is an even number, so 2 is in the sequence.
No values of 3^k+1 is ever a multiple of 3 for any integer k, so 3 is not in the sequence.
3^2+1 = 10, which is a multiple of 5, so 5 is in the sequence.
		

Crossrefs

Programs

  • Maple
    f:= p -> numtheory:-order(3,p)::even:
    f(2):= true:
    select(isprime and f, [2,seq(p,p=5..1000,2)]); # Robert Israel, May 23 2018
  • Mathematica
    Join[{2}, Select[Range[5, 1000, 2], PrimeQ[#] && EvenQ@ MultiplicativeOrder[3, #]&]] (* Jean-François Alcover, Feb 02 2023 *)
  • PARI
    isok(p)=if (p != 3, m = Mod(3, p); nb = znorder(m); for (k=1, nb, if (m^k == Mod(-1, p), return(1)););); return(0); \\ Michel Marcus, May 18 2018
    
  • PARI
    list(lim)=my(v=List([2]),t); forfactored(n=4,lim\1+1, if(n[2][,2]==[1]~, my(p=n[1],m=Mod(3,p)); for(k=2,znorder(m,t), m*=3; if(m==-1, listput(v,p); break))); t=n); Vec(v) \\ Charles R Greathouse IV, May 23 2018
    
  • PARI
    isok(p)=isprime(p)&&if(p<4,p==2,znorder(Mod(3,p))%2==0) \\ Jeppe Stig Nielsen, Jun 27 2020
    
  • PARI
    isok(p)=!isprime(p)&&return(0); p<4&&return(p==2); s=valuation(p-1,2); Mod(3,p)^((p-1)>>s)!=1 \\ Jeppe Stig Nielsen, Jun 27 2020

A301915 a(n) is the multiplicative order of 3, modulo A301913(n).

Original entry on oeis.org

4, 6, 5, 16, 18, 28, 30, 42, 52, 29, 78, 41, 88, 48, 100, 53, 112, 126, 65, 136, 138, 148, 162, 172, 89, 196, 198, 210, 222, 113, 232, 120, 125, 256, 268, 280, 282, 292, 316, 330, 168, 173, 352, 378, 388, 400, 204, 209, 146, 221, 448, 228, 460, 462, 233
Offset: 1

Author

Luke W. Richards, Mar 28 2018

Keywords

Comments

The multiplicative order of x mod y is the least positive value of z for which x^z == 1 (mod y).
Note: This is the least value for which A301913(n) divides 3^(A301914(n) + k*A(n)) + 2 for every nonnegative integer k.

Examples

			a(1) = 4 because A301913(1) = 5 and the multiplicative order of 3 modulo 5 = 4.
Note: Given a(1) = 4 and A301914(1) = 5, every value of k that can be written as k = 5 + 5j (for a nonnegative integer j) is a multiple of A301913(1) = 5.
a(7) = 30 because A301913(7) = 31 and the multiplicative order of 3 modulo 31 = 4.
Note: Given a(7) = 9 and A301914(7) = 30, every value of k that can be written as k = 30 + 9j (for a nonnegative integer j) is a multiple of A301913(7) = 31.
		

Crossrefs

A301919 a(n) is the least value of k for which A301918(n) divides 3^k+3.

Original entry on oeis.org

0, 1, 3, 4, 9, 10, 15, 16, 10, 5, 22, 27, 6, 12, 7, 40, 45, 25, 51, 18, 57, 64, 69, 70, 75, 26, 40, 82, 87, 9, 99, 100, 106, 112, 117, 61, 129, 135, 16, 141, 142, 147, 18, 159, 166, 85, 88, 177, 62, 94, 190, 195, 100, 201, 103, 74, 225, 115, 231, 232, 244, 84
Offset: 1

Author

Luke W. Richards, Mar 28 2018

Keywords

Comments

This can be used to identify P+1 values to primality test potential primes P of the form 3^k+2, i.e., A051783.

Examples

			All values of 3^k+3 are multiples of 2, so 3^0+3 = 4 is the least value of k which is a multiple of 2.
a(10) = 5 and A301918(10) = 41 so 3^5+3 = 246 is the first multiple of 41 which can be written in the form 3^k+3.
		

Crossrefs

Formula

a(n) = A301917(n-1) + 1 for n > 2.

A301914 a(n) is the least k for which A301913(n) divides 3^k+2.

Original entry on oeis.org

1, 5, 2, 6, 16, 3, 9, 6, 23, 18, 43, 4, 60, 19, 79, 25, 68, 9, 28, 78, 32, 57, 158, 137, 75, 111, 7, 22, 69, 86, 188, 65, 85, 176, 75, 64, 18, 239, 191, 286, 116, 140, 340, 338, 257, 226, 65, 23, 51, 180, 30, 207, 201, 265, 131, 481, 94, 367, 58, 85, 79
Offset: 1

Author

Luke W. Richards, Mar 28 2018

Keywords

Comments

Combined with A301913 and A301915 can be used to eliminate values of 3^k+2 from prime searches.

Examples

			A301913(1) = 5 and 5 divides 3^1+2 but not 3^0+2, so a(1)=1.
A301913(5) = 19 and 19 does not divide 3^k+2 for 0 <= k < 16, however 19 divides 3^16+2, so a(5)=16.
		

Crossrefs

Programs

  • Maple
    subs(FAIL=NULL,[seq( numtheory:-mlog(-2,3,ithprime(i)), i=3..100)]); # Robert Israel, May 04 2018

Extensions

Corrected by Robert Israel, May 04 2018

A301918 Primes which divide numbers of the form 3^k+3.

Original entry on oeis.org

2, 3, 5, 7, 17, 19, 29, 31, 37, 41, 43, 53, 61, 67, 73, 79, 89, 97, 101, 103, 113, 127, 137, 139, 149, 151, 157, 163, 173, 193, 197, 199, 211, 223, 233, 241, 257, 269, 271, 281, 283, 293, 307, 317, 331, 337, 349, 353, 367, 373, 379, 389, 397, 401, 409, 439
Offset: 1

Author

Luke W. Richards, Mar 28 2018

Keywords

Comments

Union of {3} and A301916, because 3^k + 3 = 3*(3^(k-1) + 1). [Comment edited by Jeppe Stig Nielsen, Jul 04 2020.]
Can be used to factor P+1 values where P is a potential prime of the form 3^k+2.
Is this 2 and 3 with A045318? - David A. Corneth, May 04 2018
No, it is not. Primes like 769, 1297, ... are also here but not in A045318. See A320481 for the explanation. - Jeppe Stig Nielsen, Jun 27 2020

Examples

			All values of 3^k+3 are multiples of 2, so 2 is in the sequence.
3^4+3 = 84, which is a multiple of 7, so 7 is in the sequence.
		

Crossrefs

A301913 Primes which divide numbers of the form 3^k + 2 for k >= 1.

Original entry on oeis.org

5, 7, 11, 17, 19, 29, 31, 43, 53, 59, 79, 83, 89, 97, 101, 107, 113, 127, 131, 137, 139, 149, 163, 173, 179, 197, 199, 211, 223, 227, 233, 241, 251, 257, 269, 281, 283, 293, 317, 331, 337, 347, 353, 379, 389, 401, 409, 419, 439, 443, 449, 457, 461, 463, 467
Offset: 1

Author

Luke W. Richards, Mar 28 2018

Keywords

Comments

The first odd prime not to appear in the sequence is 3 because 3^k + 2 == 2 mod 3 for k >= 1.
Primes p such that the order of -2 (mod p) divides the order of 3 (mod p). - Joerg Arndt, Mar 31 2018, corrected by Robert Israel, May 04 2018

Examples

			5 divides 245 which is 3^5+2 so 5 is in the sequence.
7 divides 245 which is 3^5+2 so 7 is in the sequence.
The values of x = (3^k+2) mod 13 for k = 0, 1, 2, 3, ... are 3, 5, 11, 3, 5, 11, ...; 13 never divides any 3^k + 2, so 13 is not in the sequence.
		

Crossrefs

Cf. A168607.

Programs

  • Maple
    select(t -> numtheory:-mlog(-2,3,t)<>FAIL, [seq(ithprime(i),i=3..100)]);
  • Mathematica
    fQ[p_] := IntegerQ@ MultiplicativeOrder[3, p, -2]; Select[ Prime@ Range@ 100, fQ] (* Robert G. Wilson v, Apr 07 2018 *)
  • PARI
    is(n)=n>4 && isprime(n) && znorder(Mod(-2,n))%znorder(Mod(3,n))==0 \\ Charles R Greathouse IV, May 04 2018

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

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

A298827 a(n) is the smallest positive integer k such that 3^n+2 divides 3^(n+k)+2.

Original entry on oeis.org

4, 5, 28, 41, 84, 336, 990, 193, 1260, 5905, 75918, 10065, 318860, 2391485, 14348908, 20390382, 5031420, 31624326, 5985168, 1743333144, 8569036, 668070480, 547062516, 141214768241, 167874004756, 1270932914165, 385131186110, 2837770056420, 784347169884, 475536631360, 149093578413164, 139370386996590
Offset: 1

Author

Luke W. Richards, Jan 27 2018

Keywords

Comments

3^n+2 divides 3^(n+a(n)*m)+2 for all nonnegative integers m.
Jon E. Schoenfield noted that a(n) coincides with the multiplicative order of 3 modulo 3^n+2. This is true because 3^(n+a(n)) == 3^n mod 3^n+2 and since 3^n and 3^n+2 are coprime, 3^a(n) == 1 mod 3^n+2 and the multiplicative order is the smallest positive such number. - Chai Wah Wu, Jan 29 2018

Examples

			For n = 1, f(1) = 3^1 + 2 = 5, where f(x) = 3^x + 2. Given the last digits of f(x) form a recurring sequence of 5, 1, 9, 3 [, 5, 1, 9, 3] then whenever x = 1 mod 4, f(x) will be a multiple of f(1).
For n = 2, f(2) = 3^2 + 2 = 11. a(2) = 5. So any x = 2 mod 5 will be a multiple of 11. For instance, 27 = 2 mod 5, and f(27) = 3^27 + 2 = 7625597474989 = 11 * 693236134999.
		

Crossrefs

Cf. A168607.

Programs

  • Magma
    [Modorder(3,3^n+2): n in [1..29]]; // Jon E. Schoenfield, Jan 28 2018
    
  • Maple
    seq(numtheory:-order(3, 3^n+2), n=1..100); # Robert Israel, Feb 05 2018
  • Mathematica
    Array[Block[{k = 1}, While[! Divisible[3^(# + k) + 2, 3^# + 2], k++]; k] &, 12] (* Michael De Vlieger, Feb 05 2018 *)
    Table[MultiplicativeOrder[3, 3^n + 2], {n, 32}] (* Jean-François Alcover, Feb 06 2018 *)
  • PARI
    a(n) = znorder(Mod(3, 3^n+2)); \\ Michel Marcus, Jan 29 2018
  • Python
    def fmod(n, mod):
        return (pow(3, n, mod) + 2) % mod
    def f(n):
        return pow(3, n) + 2
    #terms is the number of terms to generate
    terms = 20
    for x in range(1, terms + 1):
        div = f(x)
        y = x + 1
        while fmod(y, div) != 0:
            y += 1
        print(y - x)
    
  • Python
    from sympy import n_order
    def A298827(n):
        return n_order(3,3**n+2) # Chai Wah Wu, Jan 29 2018
    

Extensions

a(22)-a(32) from Robert Israel, Feb 05 2018