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.

Showing 1-5 of 5 results.

A279185 Triangle read by rows: T(n,k) (n >= 1, 0 <= k <= n-1) is the length of the period of the sequence obtained by starting with k and repeatedly squaring mod n.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 1
Offset: 1

Views

Author

N. J. A. Sloane, Dec 14 2016

Keywords

Comments

Fix n. Start with k (0 <= k <= n-1) and repeatedly square and reduce mod n until this repeats; T(n,k) is the length of the cycle that is reached.
A279186 gives maximal entry in each row.
A037178 gives maximal entry in row p, p = n-th prime.
A279187 gives maximal entry in row c, c = n-th composite number.
A279188 gives maximal entry in row c, c = prime(n)^2.
A256608 gives LCM of entries in row n.
A256607 gives T(2,n).

Examples

			The triangle begins:
1,
1,1,
1,1,1,
1,1,1,1,
1,1,1,1,1,
1,1,1,1,1,1,
1,1,2,2,2,2,1,
1,1,1,1,1,1,1,1,
1,1,2,1,2,2,1,2,1,
1,1,1,1,1,1,1,1,1,1,
1,1,4,4,4,4,4,4,4,4,1,
...
For example, if n=11 and k=2, repeatedly squaring mod 11 gives the sequence 2, 4, 5, 3, 9, 4, 5, 3, 9, 4, 5, 3, ..., which has period T(11,2) = 4.
		

Crossrefs

Programs

  • Maple
    A279185 := proc(k,n) local g,y,r;
      if k = 0 then return 1 fi;
      y:= n;
      g:= igcd(k,y);
      while g > 1 do
         y:= y/g;
         g:= igcd(k,y);
      od;
      if y = 1 then return 1 fi;
      r:= numtheory:-order(k,y);
      r:= r/2^padic:-ordp(r,2);
      if r = 1 then return 1 fi;
      numtheory:-order(2,r)
    end proc:
    seq(seq(A279185(k,n),k=0..n-1),n=1..20); # Robert Israel, Dec 14 2016
  • Mathematica
    T[n_, k_] := Module[{g, y, r}, If[k == 0, Return[1]]; y = n; g = GCD[k, y]; While[g > 1, y = y/g; g = GCD[k, y]]; If[y == 1, Return[1]]; r = MultiplicativeOrder[k, y]; r = r/2^IntegerExponent[r, 2]; If[r == 1,  Return[1]]; MultiplicativeOrder[2, r]];
    Table[T[n, k], {n, 1, 13}, {k, 0, n-1}] // Flatten (* Jean-François Alcover, Nov 27 2017, after Robert Israel *)
  • PARI
    remove_factor(k,n) = while(gcd(n,k)>1, n=n/gcd(n,k)); n; \\ gives the largest divisor of n that is coprime to k
    ord(k,n) = znorder(Mod(k,remove_factor(k,n)));
    T(n,k) = ord(2,ord(k,n)) \\ Jianing Song, Feb 02 2025

Formula

T(n,k) = ord'(2, ord'(k, n)), where ord'(k, n) is the order of k modulo the largest divisor of n that is coprime to k. - Jianing Song, Feb 02 2025

A256608 Longest eventual period of a^(2^k) mod n for all a.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 4, 1, 2, 2, 1, 1, 1, 2, 6, 1, 2, 4, 10, 1, 4, 2, 6, 2, 3, 1, 4, 1, 4, 1, 2, 2, 6, 6, 2, 1, 4, 2, 6, 4, 2, 10, 11, 1, 6, 4, 1, 2, 12, 6, 4, 2, 6, 3, 28, 1, 4, 4, 2, 1, 2, 4, 10, 1, 10, 2, 12, 2, 6, 6, 4, 6, 4, 2, 12, 1, 18, 4, 20, 2, 1, 6
Offset: 1

Views

Author

Ivan Neretin, Apr 04 2015

Keywords

Comments

a(n) is a divisor of phi(phi(n)) (A010554).

Examples

			In other words, eventual period of {0..n-1} under the map x -> x^2 mod n.
For example, with n=10 the said map acts as follows. Read down the columns: the column headed 2 for example means that (repeatedly squaring mod 10), 2 goes to 4 goes to 16 = 6 (mod 10) goes to 36 = 6 mod 10 --- and has reached a fixed point.
0 1 2 3 4 5 6 7 8 9
0 1 4 9 6 5 6 9 4 1
0 1 6 1 6 5 6 1 6 1
0 1 6 1 6 5 6 1 6 1
and thus every number reaches a fixed point. This means the eventual common period is 1, hence a(10)=1.
		

Crossrefs

First differs from A256607 at n=43.
LCM of entries in row n of A279185.

Programs

  • Mathematica
    a[n_] := With[{lambda = CarmichaelLambda[n]}, MultiplicativeOrder[2, lambda / (2^IntegerExponent[lambda, 2])]]; Table[a[n], {n, 1, 100}] (* Jean-François Alcover, Jan 28 2016 *)
  • PARI
    rpsi(n) = lcm(znstar(n)[2]); \\ A002322
    pb(n) = znorder(Mod(2, n/2^valuation(n, 2))); \\ A007733
    a(n) = pb(rpsi(n)); \\ Michel Marcus, Jan 28 2016

Formula

a(n) = A007733(A002322(n)).
a(prime(n)) = A037178(n). - Michel Marcus, Jan 27 2016

Extensions

Name changed by Jianing Song, Feb 02 2025

A141305 Primes p such that q=(p-1)/2 is also prime and 2 is a primitive root mod q; that is, q is in A001122.

Original entry on oeis.org

7, 11, 23, 59, 107, 167, 263, 347, 359, 587, 839, 887, 983, 1019, 1307, 1319, 2039, 2459, 2903, 2999, 3467, 3803, 3863, 3947, 4139, 4283, 4679, 4919, 5099, 5387, 5399, 5483, 5639, 5879, 5927, 6599, 6827, 6983, 7079, 7559, 7607, 7703, 8039, 8699, 8747
Offset: 1

Views

Author

T. D. Noe, Jun 24 2008

Keywords

Comments

These primes are a subset of the safe primes, A005385. These primes produce the longest possible cycles, (p-3)/2, in the squaring mod p map. See A037178.

Crossrefs

Programs

  • Mathematica
    Select[Range[10^4], PrimeQ[#] && PrimeQ[(q = (# - 1)/2)] && PrimitiveRoot[q] == 2 &] (* Amiram Eldar, Oct 09 2021 *)
  • PARI
    isok(p) = isprime(p) && (p%2) && isprime(q=(p-1)/2) && (q%2) && (znorder(Mod(2, q))==(q-1)); \\ Michel Marcus, Jan 30 2016

Extensions

Incorrect term 5 removed by Michel Marcus, Jan 30 2016

A037179 Number of cycles when squaring modulo n-th prime.

Original entry on oeis.org

2, 2, 2, 3, 3, 3, 2, 4, 3, 4, 6, 4, 3, 7, 4, 3, 3, 6, 6, 7, 4, 6, 4, 3, 3, 4, 9, 3, 5, 4, 14, 8, 4, 7, 3, 9, 6, 6, 3, 5, 10, 9, 6, 3, 6, 9, 16, 6, 6, 6, 3, 10, 6, 5, 2, 3, 3, 12, 7, 7, 7, 10, 14, 15, 6, 4, 15, 7, 3, 6, 3, 3, 6, 15, 21, 4, 4, 9, 4, 9, 6, 16, 12, 5, 19, 13, 4, 6, 7, 16, 10, 4, 7, 11, 6
Offset: 1

Views

Author

Keywords

Comments

Note that Rogers and Shallit give the formula for F*p and Rogers has a table with a(n)-1. - Michel Marcus, Jan 30 2016

Crossrefs

Programs

  • Mathematica
    odd[n_] := n/2^IntegerExponent[n,2]; a[n_] := 1 + DivisorSum[odd[Prime[n]-1], EulerPhi[#]/MultiplicativeOrder[2, #] &]; Array[a, 100] (* Amiram Eldar, Aug 29 2023 *)
  • PARI
    rho(p) = {my(m = p-1); m >> valuation(m, 2);}
    a(n) = {my(r = rho(prime(n))) ; 1+ sumdiv(r, d, eulerphi(d)/znorder(Mod(2,d)));} \\ Michel Marcus, Jan 30 2016

Formula

a(n) = 1+ Sum_{d|rho} phi(d)/ord(2,d) with rho the largest odd factor of prime(n)-1 (rho = A000265(p-1)). The 1 corresponds to the sink 0. - Michel Marcus, Jan 30 2016

A037180 Number of different cycle lengths when squaring modulo n-th prime.

Original entry on oeis.org

1, 1, 1, 2, 2, 2, 1, 3, 2, 2, 3, 3, 2, 4, 2, 2, 2, 3, 3, 4, 3, 3, 2, 2, 2, 3, 3, 2, 4, 2, 4, 3, 2, 4, 2, 4, 3, 5, 2, 2, 2, 5, 4, 2, 3, 5, 6, 3, 2, 3, 2, 4, 3, 4, 1, 2, 2, 7, 4, 4, 4, 2, 5, 4, 3, 2, 5, 4, 2, 3, 2, 2, 3, 4, 5, 2, 2, 5, 3, 3, 4, 6, 4, 4, 4, 4, 2, 3, 4, 6, 2, 2, 6, 6, 3, 2, 2, 3, 5, 7, 5, 2
Offset: 1

Views

Author

Keywords

Crossrefs

Showing 1-5 of 5 results.