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.

A046144 Number of primitive roots modulo n.

This page as a plain text file.
%I A046144 #53 Feb 16 2025 08:32:38
%S A046144 1,1,1,1,2,1,2,0,2,2,4,0,4,2,0,0,8,2,6,0,0,4,10,0,8,4,6,0,12,0,8,0,0,
%T A046144 8,0,0,12,6,0,0,16,0,12,0,0,10,22,0,12,8,0,0,24,6,0,0,0,12,28,0,16,8,
%U A046144 0,0,0,0,20,0,0,0,24,0,24,12,0,0,0,0,24,0,18,16,40,0,0,12,0,0,40,0,0
%N A046144 Number of primitive roots modulo n.
%H A046144 T. D. Noe, <a href="/A046144/b046144.txt">Table of n, a(n) for n = 1..10000</a>
%H A046144 S. R. Finch, <a href="https://arxiv.org/abs/math/0605019">Idempotents and Nilpotents Modulo n</a>, arXiv:math/0605019 [math.NT], 2006-2017.
%H A046144 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/PrimitiveRoot.html">Primitive Root.</a>
%F A046144 a(n) is equal to A010554(n) unless n is a term of A033949, in which case a(n)=0.
%p A046144 A046144 := proc(n)
%p A046144     local a,eulphi,m;
%p A046144     if n = 1 then
%p A046144         return 1;
%p A046144     end if;
%p A046144     eulphi := numtheory[phi](n) ;
%p A046144     a := 0 ;
%p A046144     for m from 0 to n-1 do
%p A046144         if numtheory[order](m,n) = eulphi then
%p A046144             a := a + 1 ;
%p A046144         end if;
%p A046144     end do:
%p A046144     a;
%p A046144 end proc: # _R. J. Mathar_, Jan 12 2016
%t A046144 Prepend[ Table[ If[ IntegerQ[ PrimitiveRoot[n]] , EulerPhi[ EulerPhi[n]], 0], {n, 2, 91}],1] (* _Jean-François Alcover_, Sep 13 2011 *)
%o A046144 (PARI) for(i=1, 100, p=0; for(q=1, i, if(gcd(q,i)==1 && znorder(Mod(q,i)) == eulerphi(i), p++)); print1(p, ", ")) /* _V. Raman_, Nov 22 2012 */
%o A046144 (PARI) a(n) = my(s=znstar(n)); if(#(s.cyc)>1, 0, eulerphi(s.no)) \\ _Jeppe Stig Nielsen_, Oct 18 2019
%o A046144 (Perl) use ntheory ":all"; my @A = map { !defined znprimroot($_) ? 0 : euler_phi(euler_phi($_)); } 0..10000; say "$_ $A[$_]" for 1..$#A; # _Dana Jacobsen_, Apr 28 2017
%Y A046144 Cf. A001918, A010554, A033949, A046145, A046146, A008330, A002233, A071894, A219027.
%K A046144 nonn
%O A046144 1,5
%A A046144 _Eric W. Weisstein_