%I #8 Oct 03 2019 05:03:06
%S 1,1,1,2,1,1,1,4,3,1,1,2,1,1,2,8,1,3,1,2,2,1,1,4,5,1,9,2,1,2,1,16,2,1,
%T 2,6,1,1,2,4,1,2,1,2,6,1,1,8,7,5,2,2,1,9,2,4,2,1,1,4,1,1,6,32,2,2,1,2,
%U 2,2,1,12,1,1,10,2,2,2,1,8,27,1,1,4,2,1,2,4,1,6,2,2,2,1,2,16,1,7,6,10
%N Let j(n) be the Jacobsthal function, A048669. Then a(n) is the number of times that the gap j(n) appears between consecutive numbers <= n+1 and coprime to n.
%C Differs from A087653 starting at n=35. For prime n and e>0, a(n^e)=n^(e-1). The closely-related sequence A128707 satisfies the inequality a(n)*A128707(n) <= n-1, with equality for prime n. If m is the squarefree kernel of n (A007947), then a(n)/a(m) = n/m.
%H T. D. Noe, <a href="/A128708/b128708.txt">Table of n, a(n) for n=1..10000</a>
%e The numbers coprime to 15 are 1,2,4,7,8,11,13,14,16,17,19,22,... Observe that the differences are periodic: 1,2,3,1,3,2,1,2,1,2,3,... The maximum value is 3, which occurs twice in the first period. Hence a(15)=2.
%t JacobsthalCount[n_] := Module[{g,d,mx}, g=Select[Range[n+1], GCD[n,# ]==1&]; d=Rest[g]-Most[g]; mx=Max@@d; Count[d,mx]]; Table[JacobsthalCount[n], {n,100}]
%K nonn
%O 1,4
%A _T. D. Noe_, Mar 24 2007