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-3 of 3 results.

A046147 Triangle read by rows in which row n lists the primitive roots mod n (omitting numbers n without a primitive root).

Original entry on oeis.org

1, 2, 3, 2, 3, 5, 3, 5, 2, 5, 3, 7, 2, 6, 7, 8, 2, 6, 7, 11, 3, 5, 3, 5, 6, 7, 10, 11, 12, 14, 5, 11, 2, 3, 10, 13, 14, 15, 7, 13, 17, 19, 5, 7, 10, 11, 14, 15, 17, 19, 20, 21, 2, 3, 8, 12, 13, 17, 22, 23, 7, 11, 15, 19, 2, 5, 11, 14, 20, 23, 2, 3, 8, 10, 11, 14, 15, 18, 19, 21, 26
Offset: 2

Views

Author

Keywords

Examples

			n followed by primitive roots, if any:
1 -
2 1
3 2
4 3
5 2 3
6 5
7 3 5
8 -
9 2 5
10 3 7
11 2 6 7 8
12 -
13 2 6 7 11
...
		

Crossrefs

Cf. A001918, A046144 (row lengths), A046145, A046146.
Cf. A060749, A306252 (1st column), A306253 (last/maximum element)

Programs

  • Maple
    f:= proc(n) local p,k,m,R;
         p:= numtheory:-primroot(n);
         if p = FAIL then return NULL fi;
         m:= numtheory:-phi(n);
         k:= select(i -> igcd(i,m) = 1, [$1..m-1]);
         op(sort(map(t -> p&^t mod n, k)))
    end proc:
    f(2):= 1:
    map(f, [$2..50]); # Robert Israel, Apr 28 2017
  • Mathematica
    a[n_] := Select[Range[n-1], GCD[#, n] == 1 && MultiplicativeOrder[#, n] == EulerPhi[n]& ]; Table[a[n], {n, 1, 30}] // Flatten (* Jean-François Alcover, Oct 23 2012 *)
    PrimitiveRootList[Range[Prime[10]]]//Flatten (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Sep 10 2016 *)
  • PARI
    a_row(r) = my(v=[], phi=eulerphi(r)); for(i=1, r-1, if(1 == gcd(r, i) && phi == znorder(Mod(i, r)), v=concat(v, i))); v \\ Ruud H.G. van Tol, Oct 23 2023

Extensions

Edited by Robert Israel, Apr 28 2017

A306253 Largest primitive root mod A033948(n).

Original entry on oeis.org

0, 1, 2, 3, 3, 5, 5, 5, 7, 8, 11, 5, 14, 11, 15, 19, 21, 23, 19, 23, 27, 24, 31, 35, 33, 35, 34, 43, 45, 47, 47, 51, 47, 55, 56, 59, 55, 63, 69, 68, 69, 77, 77, 75, 80, 77, 86, 91, 92, 89, 99, 101, 103, 104, 103, 110, 115, 117, 115, 123, 118, 128, 117, 134, 135
Offset: 1

Views

Author

Charles Paul, Feb 01 2019

Keywords

Comments

Let U(k) denote the multiplicative group mod k. a(n) = largest generator for U(A033948(n)). - N. J. A. Sloane, Mar 10 2019

Examples

			For n=2, U(n) is generated by 1.
For n=14, A033948(14) = 18, and, U(n) is generated by both 5 and 11; here we select the largest generator, 11, so a(14) = 11.
		

Crossrefs

See A306252 for smallest roots and A033948 for the sequence of numbers that have a primitive root.

Programs

  • Maple
    f:= proc(b) local x, t;
      t:= numtheory:-phi(b);
      for x from b-1 by -1 do if igcd(x,b) = 1 and numtheory:-order(x,b)=t then return x fi od
    end proc:
    f(1):= 0:
    cands:= select(t -> t=1 or numtheory:-primroot(t) <> FAIL, [$1..1000]):
    map(f, cands); # Robert Israel, Mar 10 2019
  • Mathematica
    Join[{0}, Last /@ DeleteCases[PrimitiveRootList[Range[1000]], {}]] (* Jean-François Alcover, Jun 18 2020 *)
  • Python
    def gcd(x, y):
        # Euclid's Algorithm
        while(y):
            x, y = y, x % y
        return x
    roots = [0]
    for n in range(2, 140):
        # find U(n)
        un = [i for i in range(n, 0, -1) if (gcd(i, n) == 1)]
        # for each element in U(n), check if it's a generator
        order = len(un)
        is_cyclic = False
        for cand in un:
            is_gen = True
            run = 1
            # If it cand^x = 1 for some x < order, it's not a generator
            for _ in range(order-1):
                run = (run * cand) % n
                if run == 1:
                    is_gen = False
                    break
            if is_gen:
                roots.append(cand)
                is_cyclic = True
                break
    print("roots:", roots)

Extensions

Edited by N. J. A. Sloane, Mar 10 2019.

A081888 Numbers n such that the least positive primitive root of n is larger than the value for all positive numbers smaller than n.

Original entry on oeis.org

1, 3, 4, 6, 22, 118, 191, 362, 842, 2042, 2342, 3622, 16022, 29642, 66602, 110881, 143522, 535802, 5070662, 6252122, 6497402, 10219442, 69069002, 1130187962
Offset: 1

Views

Author

Sven Simon, Mar 30 2003

Keywords

Comments

A081889 gives the primitive roots itself. Difference from A002229, A002230: In consideration of all n having primitive roots. A002229, A002230 only primes.

Crossrefs

Cf. A081889, A002229, A002230. Positions of records of A306252.

Programs

  • Maple
    a306252 := proc(n::integer)
        local r;
        r := numtheory[primroot](n) ;
        if r <> FAIL then
            return r ;
        else
            return -1 ;
        end if;
    end proc:
    A081888 := proc()
        local rec,n,lpr ;
        rec := -1 ;
        for n from 1 do
            lpr := a306252(n) ;
            if lpr > rec then
                printf("%d,\n",n) ;
                rec := lpr ;
            end if;
        end do:
    end proc:
    A081888() ; # R. J. Mathar, Apr 04 2019
  • Mathematica
    nmax = 10^5;
    r[n_] := r[n] = Module[{prl = PrimitiveRootList[n]}, If[prl == {}, -1, prl[[1]]]]; r[1] = 1;
    Reap[Module[{rec = -1, n, lpr}, For[n = 1, n <= nmax, n++, lpr = r[n]; If[lpr > rec, Print[n, " ", lpr]; Sow[n]; rec = lpr]]]][[2, 1]] (* Jean-François Alcover, Jun 19 2023, after R. J. Mathar *)
  • Python
    from sympy import primitive_root
    from itertools import count, islice
    def f(n): r = primitive_root(n); return r if r != None else 0
    def agen(r=0): yield from ((m, r:=f(m))[0] for m in count(1) if f(m) > r)
    print(list(islice(agen(), 18))) # Michael S. Branicky, Feb 13 2023

Formula

Numbers 1, 2, 4, p^m and 2*p^m have primitive roots for odd primes p and m >=1 natural number.

Extensions

a(24) from Michael S. Branicky, Feb 20 2023
Showing 1-3 of 3 results.