login
a(n) = number of positive integers < n that are coprime to exactly one prime divisor of n.
4

%I #19 Oct 30 2017 22:39:10

%S 0,1,2,2,4,3,6,4,6,5,10,6,12,7,6,8,16,9,18,10,8,11,22,12,20,13,18,14,

%T 28,7,30,16,12,17,10,18,36,19,14,20,40,9,42,22,18,23,46,24,42,25,18,

%U 26,52,27,14,28,20,29,58,14,60,31,24,32,16,13,66,34,24,11,70,36,72,37,30,38

%N a(n) = number of positive integers < n that are coprime to exactly one prime divisor of n.

%H Michael De Vlieger, <a href="/A126080/b126080.txt">Table of n, a(n) for n = 1..10000</a>

%F a(p) = p - 1.

%e Concerning a(12): 1,5,7,11 are coprime to each prime dividing 12; so these integers are not counted. 6 is coprime to 0 primes dividing 12; so this integer is not counted. But the 6 integers 2,3,4,8,9,10 are each coprime to exactly one prime dividing 12; so a(12) = 6.

%e Concerning a(30): Only the 7 integers 6,10,12,15,18,20,24 are each coprime to exactly one prime dividing 30. So a(30) = 7.

%p A126080 := proc(n) local divs,pdivs,a,i,pcnt,p; divs := numtheory[divisors](n); pdivs := []; for i from 1 to nops(divs) do if isprime(op(i,divs)) then pdivs := [op(pdivs),op(i,divs)]; fi; od; a := 0; for i from 1 to n-1 do pcnt := 0; for p from 1 to nops(pdivs) do if gcd(i,op(p,pdivs)) = 1 then pcnt := pcnt+1; fi; od; if pcnt = 1 then a := a+1; fi; od; RETURN(a); end: for n from 1 to 90 do printf("%d, ",A126080(n)); od; # _R. J. Mathar_, Mar 14 2007

%t Table[Count[Range[n - 1], k_ /; Total@ Boole@ Map[CoprimeQ[k, #] &, #] == 1] &[FactorInteger[n][[All, 1]]], {n, 76}] (* _Michael De Vlieger_, Sep 19 2017 *)

%o (PARI) a(n) = my(f=factor(n)); #select(x->(x==1), vector(n-1, j, sum(k=1, #f~, gcd(j, f[k,1]) == 1))); \\ _Michel Marcus_, Oct 25 2017

%Y Cf. A128487, A128488.

%K nonn

%O 1,3

%A _Leroy Quet_, Mar 02 2007

%E More terms from _R. J. Mathar_, Mar 14 2007