login
Counting factor 7 in the first n squarefree numbers.
5

%I #24 Feb 24 2021 03:51:34

%S 0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5,5,5,

%T 5,5,5,5,5,5,5,5,5,6,6,6,6,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,

%U 9,9,9,9,9,9,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,12

%N Counting factor 7 in the first n squarefree numbers.

%H Reinhard Zumkeller, <a href="/A072750/b072750.txt">Table of n, a(n) for n = 1..10000</a>

%F a(n) - a(n-1) = 1 if A005117(n) is in A008589, otherwise 0. - _Robert Israel_, Aug 23 2015

%F a(n) ~ n/8. - _Amiram Eldar_, Feb 24 2021

%e The first 10 squarefree numbers are: 1, 2, 3, 5, 6=2*3, 7, 10=2*5, 11, 13 and 14=2*7: 7 and 14 are divisible by 7, therefore a(10)=2.

%p N:= 1000: # to use the squarefree numbers <= N

%p M:= map(proc(t) if numtheory:-issqrfree(t) then if t mod 7 = 0 then 1 else 0 fi fi end proc, [$1..N]):

%p ListTools:-PartialSums(M); # _Robert Israel_, Aug 23 2015

%t With[{sf=Select[Range[200],SquareFreeQ]},Accumulate[If[Divisible[#,7],1,0]&/@sf]] (* _Harvey P. Dale_, Mar 21 2013 *)

%o (Haskell)

%o a072750 n = a072750_list !! (n-1)

%o a072750_list = scanl1 (+) $ map ((0 ^) . (`mod` 7)) a005117_list

%o -- _Reinhard Zumkeller_, Mar 25 2013

%o (PARI)

%o n = 94; k = 0; bag = List(); a = vector(n);

%o until(n == 0, k++; if (issquarefree(k), listput(bag, k); n--));

%o for (i=2, #bag, a[i] = a[i-1] + (bag[i] % 7 == 0));

%o print(a); \\ _Gheorghe Coserea_, Aug 23 2015

%Y Cf. A005117, A008589, A072747, A072748, A072749, A072751.

%K nonn

%O 1,10

%A _Reinhard Zumkeller_, Jul 08 2002

%E Name clarified by _Gheorghe Coserea_, Aug 23 2015